- if (mach_port_names(task, &names, &ncnt,
- &types, &tcnt) == KERN_SUCCESS) {
- pi->num_ports = ncnt;
- pi->orig_num_ports = ncnt;
- (void) vm_deallocate(mach_task_self(),
- (vm_offset_t) names,
- ncnt * sizeof(*names));
- (void) vm_deallocate(mach_task_self(),
- (vm_offset_t) types,
- tcnt * sizeof(*types));
- } else {
- pi->num_ports = -1;
- }
-
+ if (!events_only) {
+ if (mach_port_names(task, &names, &ncnt,
+ &types, &tcnt) == KERN_SUCCESS) {
+ pi->num_ports = ncnt;
+ pi->orig_num_ports = ncnt;
+ (void) vm_deallocate(mach_task_self(),
+ (vm_offset_t) names,
+ ncnt * sizeof(*names));
+ (void) vm_deallocate(mach_task_self(),
+ (vm_offset_t) types,
+ tcnt * sizeof(*types));
+ } else {
+ pi->num_ports = -1;
+ }
+ } else
+ pi->num_ports = 0;
+