2 * Copyright (c) 2015-2016 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
32 #include <sys/types.h>
33 #include <sys/event.h>
35 #include <sys/proc_info.h>
36 #include <sys/param.h>
37 #include <pthread/pthread.h>
38 #include <mach/message.h>
42 #include <os/assumes.h>
43 #include <os/overflow.h>
47 #define ARRAYLEN(x) (sizeof((x))/sizeof((x[0])))
49 /* command line options */
52 static int ignore_empty
;
55 static char *self
= "lskq";
57 static inline const char *
58 filt_name(int16_t filt
)
60 static char unkn_filt
[32];
62 if (idx
>= 0 && idx
< ARRAYLEN(filt_strs
)) {
63 return filt_strs
[idx
];
65 snprintf(unkn_filt
, sizeof(unkn_filt
), "%i (?)", idx
);
70 static inline const char *
71 fdtype_str(uint32_t type
)
73 static char unkn_fdtype
[32];
74 if (type
< ARRAYLEN(fdtype_strs
)) {
75 return fdtype_strs
[type
];
77 snprintf(unkn_fdtype
, sizeof(unkn_fdtype
), "%i (?)", type
);
83 fflags_build(struct kevent_extinfo
*info
, char *str
, int len
)
85 unsigned ff
= info
->kqext_sfflags
;
87 switch (info
->kqext_kev
.filter
) {
90 snprintf(str
, len
, "%c ",
91 (ff
& NOTE_LOWAT
) ? 'l' : '-'
96 case EVFILT_MACHPORT
: {
97 snprintf(str
, len
, "%c ",
98 (ff
& MACH_RCV_MSG
) ? 'r' : '-'
104 snprintf(str
, len
, "%c%c%c%c%c%c%c",
105 (ff
& NOTE_DELETE
) ? 'd' : '-',
106 (ff
& NOTE_WRITE
) ? 'w' : '-',
107 (ff
& NOTE_EXTEND
) ? 'e' : '-',
108 (ff
& NOTE_ATTRIB
) ? 'a' : '-',
109 (ff
& NOTE_LINK
) ? 'l' : '-',
110 (ff
& NOTE_RENAME
) ? 'r' : '-',
111 (ff
& NOTE_REVOKE
) ? 'v' : '-'
117 /* NOTE_REAP is deprecated, but we still want to show if it's used */
118 #pragma clang diagnostic push
119 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
120 snprintf(str
, len
, "%c%c%c%c%c%c%c",
121 (ff
& NOTE_EXIT
) ? 'x' : '-',
122 (ff
& NOTE_EXITSTATUS
) ? 't' : '-',
123 (ff
& NOTE_EXIT_DETAIL
)? 'd' : '-',
124 (ff
& NOTE_FORK
) ? 'f' : '-',
125 (ff
& NOTE_EXEC
) ? 'e' : '-',
126 (ff
& NOTE_SIGNAL
) ? 's' : '-',
127 (ff
& NOTE_REAP
) ? 'r' : '-'
130 #pragma clang diagnostic pop
134 snprintf(str
, len
, "%c%c%c%c%c ",
135 (ff
& NOTE_SECONDS
) ? 's' :
136 (ff
& NOTE_USECONDS
) ? 'u' :
137 (ff
& NOTE_NSECONDS
) ? 'n' : '?',
138 (ff
& NOTE_ABSOLUTE
) ? 'a' : '-',
139 (ff
& NOTE_CRITICAL
) ? 'c' : '-',
140 (ff
& NOTE_BACKGROUND
) ? 'b' : '-',
141 (ff
& NOTE_LEEWAY
) ? 'l' : '-'
147 snprintf(str
, len
, "%c%c%c ",
148 (ff
& NOTE_TRIGGER
) ? 't' : '-',
149 (ff
& NOTE_FFAND
) ? 'a' : '-',
150 (ff
& NOTE_FFOR
) ? 'o' : '-'
154 case EVFILT_WORKLOOP
:
155 snprintf(str
, len
, "%c%c%c%c ",
156 (ff
& NOTE_WL_THREAD_REQUEST
) ? 't' :
157 (ff
& NOTE_WL_SYNC_WAIT
) ? 'w' : '-',
158 (ff
& NOTE_WL_SYNC_WAKE
) ? '!' : '-',
159 (ff
& NOTE_WL_UPDATE_QOS
) ? 'q' : '-',
160 (ff
& NOTE_WL_UPDATE_OWNER
) ? 'O' :
161 (ff
& NOTE_WL_DISCOVER_OWNER
) ? 'o' : '-'
166 snprintf(str
, len
, "");
175 filter_is_fd_type(int filter
)
178 case EVFILT_VNODE
... EVFILT_READ
:
180 case EVFILT_NW_CHANNEL
:
188 thread_qos_name(uint8_t th_qos
)
199 default: return "??";
204 * find index of fd in a list of fdinfo of length nfds
207 fd_list_getfd(struct proc_fdinfo
*fds
, int nfds
, int fd
)
210 for (i
= 0; i
< nfds
; i
++) {
211 if (fds
[i
].proc_fd
== fd
) {
220 * left truncate URL-form process names
223 shorten_procname(const char *proc
, int width
)
225 if (strcasestr(proc
, "com.") == proc
) {
226 long len
= strlen(proc
);
228 return &proc
[len
- width
];
238 * stringify knote ident where possible (signals, processes)
241 print_ident(uint64_t ident
, int16_t filter
, int width
)
244 printf("%#*llx ", width
, ident
);
255 int numlen
= sprintf(num
, "%llu", ident
);
256 int strwidth
= width
- numlen
- 1; // add room for a space
258 if (filter
== EVFILT_SIGNAL
) {
259 if (ident
< ARRAYLEN(sig_strs
)) {
260 snprintf(str
, strwidth
+ 1, "%s", sig_strs
[ident
]);
263 /* FIXME: this should be cached */
264 struct proc_bsdinfo bsdinfo
;
265 int ret
= proc_pidinfo((int)ident
, PROC_PIDTBSDINFO
, 0, &bsdinfo
, sizeof(bsdinfo
));
266 if (ret
== sizeof(bsdinfo
)) {
267 char *procname
= bsdinfo
.pbi_name
;
268 if (strlen(procname
) == 0) {
269 procname
= bsdinfo
.pbi_comm
;
271 snprintf(str
, strwidth
+ 1, "%s", shorten_procname(procname
, strwidth
));
275 if (str
[0] != '\0') {
276 snprintf(out
, width
+ 1, "%-*s %s", strwidth
, str
, num
);
278 snprintf(out
, width
+ 1, "%s", num
);
281 printf("%*s ", width
, out
);
285 case EVFILT_MACHPORT
:
287 /* hex, to match lsmp */
288 printf("%#*llx ", width
, ident
);
291 case EVFILT_WORKLOOP
:
292 printf("%#*llx ", width
, ident
);
296 printf("%*llu ", width
, ident
);
303 print_kqid(int state
, uint64_t kqid
)
305 if (state
& KQ_WORKQ
) {
306 printf("%18s ", "wq");
307 } else if (state
& KQ_WORKLOOP
) {
308 printf("%#18" PRIx64
" ", kqid
);
310 printf("fd %15" PRIi64
" ", kqid
);
314 #define PROCNAME_WIDTH 20
317 print_kq_info(int pid
, const char *procname
, uint64_t kqid
, int state
)
321 print_kqid(state
, kqid
);
322 printf("%#10x ", state
);
324 char tmpstr
[PROCNAME_WIDTH
+1];
325 strlcpy(tmpstr
, shorten_procname(procname
, PROCNAME_WIDTH
), PROCNAME_WIDTH
+1);
326 printf("%-*s ", PROCNAME_WIDTH
, tmpstr
);
328 print_kqid(state
, kqid
);
330 (state
& KQ_SLEEP
) ? 'k' : '-',
331 (state
& KQ_SEL
) ? 's' : '-',
332 (state
& KQ_WORKQ
) ? 'q' :
333 (state
& KQ_WORKLOOP
) ? 'l' : '-'
343 #define POLICY_TIMESHARE 1
345 #define POLICY_FIFO 4
348 process_kqueue(int pid
, const char *procname
, enum kqtype type
, uint64_t kqid
,
349 struct proc_fdinfo
*fdlist
, int nfds
)
353 int maxknotes
= 256; /* arbitrary starting point */
355 bool is_kev_64
, is_kev_qos
;
357 bool overflow
= false;
359 bool dynkq_printed
= false;
362 * get the basic kqueue info
364 struct kqueue_fdinfo kqfdinfo
= {};
365 struct kqueue_dyninfo kqinfo
= {};
368 ret
= proc_pidfdinfo(pid
, (int)kqid
, PROC_PIDFDKQUEUEINFO
, &kqfdinfo
, sizeof(kqfdinfo
));
372 ret
= proc_piddynkqueueinfo(pid
, PROC_PIDDYNKQUEUE_INFO
, kqid
, &kqinfo
, sizeof(kqinfo
));
375 os_crash("invalid kqueue type");
378 if (type
== KQTYPE_FD
&& (int)kqid
!= -1) {
379 if (ret
!= sizeof(kqfdinfo
)) {
380 /* every proc has an implicit workq kqueue, dont warn if its unused */
381 fprintf(stderr
, "WARN: FD table changed (pid %i, kq %i)\n", pid
,
384 } else if (type
== KQTYPE_DYNAMIC
) {
385 if (ret
< sizeof(struct kqueue_info
)) {
386 fprintf(stderr
, "WARN: kqueue missing (pid %i, kq %#" PRIx64
")\n",
389 kqfdinfo
.kqueueinfo
= kqinfo
.kqdi_info
;
391 if (verbose
&& ret
>= sizeof(struct kqueue_dyninfo
)) {
392 print_kq_info(pid
, procname
, kqid
, kqinfo
.kqdi_info
.kq_state
);
394 printf("%18s ", " "); // ident
395 printf("%-9s ", " "); // filter
396 dynkq_printed
= true;
399 printf("%-10s ", " "); // fflags
400 printf("%-10s ", " "); // flags
401 printf("%-10s ", " "); // evst
403 printf("%-8s ", " "); // fdtype
405 switch (kqinfo
.kqdi_pol
) {
411 case POLICY_TIMESHARE
:
417 snprintf(tmpstr
, 4, "%c%c%c", (kqinfo
.kqdi_pri
== 0)?'-':'P', policy_type
, (kqinfo
.kqdi_cpupercent
== 0)?'-':'%');
418 printf("%-7s ", tmpstr
); // fflags
419 printf("%-15s ", " "); // flags
420 printf("%-17s ", " "); // evst
423 if (!raw
&& kqinfo
.kqdi_pri
!= 0) {
424 printf("%3d ", kqinfo
.kqdi_pri
); //qos
426 int qos
= MAX(MAX(kqinfo
.kqdi_events_qos
, kqinfo
.kqdi_async_qos
),
427 kqinfo
.kqdi_sync_waiter_qos
);
428 printf("%3s ", thread_qos_name(qos
)); //qos
430 printf("%-18s ", " "); // data
431 printf("%-18s ", " "); // udata
432 printf("%#18llx ", kqinfo
.kqdi_servicer
); // ext0
433 printf("%#18llx ", kqinfo
.kqdi_owner
); // ext1
439 * get extended kqueue info
441 struct kevent_extinfo
*kqextinfo
= NULL
;
444 kqextinfo
= malloc(sizeof(struct kevent_extinfo
) * maxknotes
);
448 perror("failed allocating memory");
455 nknotes
= proc_pidfdinfo(pid
, fd
, PROC_PIDFDKQUEUE_EXTINFO
,
456 kqextinfo
, sizeof(struct kevent_extinfo
) * maxknotes
);
459 nknotes
= proc_piddynkqueueinfo(pid
, PROC_PIDDYNKQUEUE_EXTINFO
, kqid
,
460 kqextinfo
, sizeof(struct kevent_extinfo
) * maxknotes
);
463 os_crash("invalid kqueue type");
468 /* proc_*() can't distinguish between error and empty list */
469 } else if (errno
== EAGAIN
) {
471 } else if (errno
== EBADF
) {
472 fprintf(stderr
, "WARN: FD table changed (pid %i, kq %#" PRIx64
")\n", pid
, kqid
);
476 perror("failed to get extended kqueue info");
481 if (nknotes
> maxknotes
) {
482 maxknotes
= nknotes
+ 16; /* arbitrary safety margin */
488 if (nknotes
>= PROC_PIDFDKQUEUE_KNOTES_MAX
) {
492 kq_state
= kqfdinfo
.kqueueinfo
.kq_state
;
493 is_kev_64
= (kq_state
& PROC_KQUEUE_64
);
494 is_kev_qos
= (kq_state
& PROC_KQUEUE_QOS
);
497 if (!ignore_empty
&& !dynkq_printed
) {
498 /* for empty kqueues, print a single empty entry */
499 print_kq_info(pid
, procname
, kqid
, kq_state
);
500 printf("%18s \n", "-");
505 for (i
= 0; i
< nknotes
; i
++) {
506 struct kevent_extinfo
*info
= &kqextinfo
[i
];
508 print_kq_info(pid
, procname
, kqid
, kqfdinfo
.kqueueinfo
.kq_state
);
509 print_ident(info
->kqext_kev
.ident
, info
->kqext_kev
.filter
, 18);
510 printf("%-9s ", filt_name(info
->kqext_kev
.filter
));
513 printf("%#10x ", info
->kqext_sfflags
);
514 printf("%#10x ", info
->kqext_kev
.flags
);
515 printf("%#10x ", info
->kqext_status
);
517 /* for kevents attached to file descriptors, print the type of FD (file, socket, etc) */
518 const char *fdstr
= "";
519 if (filter_is_fd_type(info
->kqext_kev
.filter
)) {
521 int knfd
= fd_list_getfd(fdlist
, nfds
, (int)info
->kqext_kev
.ident
);
523 fdstr
= fdtype_str(fdlist
[knfd
].proc_fdtype
);
526 printf("%-8s ", fdstr
);
528 /* print filter flags */
529 printf("%7s ", fflags_build(info
, tmpstr
, sizeof(tmpstr
)));
531 /* print generic flags */
532 unsigned flg
= info
->kqext_kev
.flags
;
533 printf("%c%c%c%c %c%c%c%c %c%c%c%c%c ",
534 (flg
& EV_ADD
) ? 'a' : '-',
535 (flg
& EV_ENABLE
) ? 'n' : '-',
536 (flg
& EV_DISABLE
) ? 'd' : '-',
537 (flg
& EV_DELETE
) ? 'x' : '-',
539 (flg
& EV_RECEIPT
) ? 'r' : '-',
540 (flg
& EV_ONESHOT
) ? '1' : '-',
541 (flg
& EV_CLEAR
) ? 'c' : '-',
542 (flg
& EV_DISPATCH
) ? 's' : '-',
544 (flg
& EV_UDATA_SPECIFIC
) ? 'u' : '-',
545 (flg
& EV_FLAG0
) ? 'p' : '-',
546 (flg
& EV_FLAG1
) ? 'b' : '-',
547 (flg
& EV_EOF
) ? 'o' : '-',
548 (flg
& EV_ERROR
) ? 'e' : '-'
551 unsigned st
= info
->kqext_status
;
552 printf("%c%c%c%c %c%c%c%c %c%c%c%c %c%c ",
553 (st
& KN_ACTIVE
) ? 'a' : '-',
554 (st
& KN_QUEUED
) ? 'q' : '-',
555 (st
& KN_DISABLED
) ? 'd' : '-',
556 (st
& KN_STAYACTIVE
) ? 's' : '-',
558 (st
& KN_DROPPING
) ? 'd' : '-',
559 (st
& KN_USEWAIT
) ? 'w' : '-',
560 (st
& KN_ATTACHING
) ? 'c' : '-',
561 (st
& KN_ATTACHED
) ? 'a' : '-',
563 (st
& KN_DISPATCH
) ? 's' : '-',
564 (st
& KN_UDATA_SPECIFIC
) ? 'u' : '-',
565 (st
& KN_SUPPRESSED
) ? 'p' : '-',
566 (st
& KN_STOLENDROP
) ? 't' : '-',
568 (st
& KN_REQVANISH
) ? 'v' : '-',
569 (st
& KN_VANISHED
) ? 'n' : '-'
573 printf("%3s ", thread_qos_name(info
->kqext_kev
.qos
));
575 printf("%#18llx ", (unsigned long long)info
->kqext_kev
.data
);
578 printf("%#18llx ", (unsigned long long)info
->kqext_kev
.udata
);
579 if (is_kev_qos
|| is_kev_64
) {
580 printf("%#18llx ", (unsigned long long)info
->kqext_kev
.ext
[0]);
581 printf("%#18llx ", (unsigned long long)info
->kqext_kev
.ext
[1]);
584 printf("%#18llx ", (unsigned long long)info
->kqext_kev
.ext
[2]);
585 printf("%#18llx ", (unsigned long long)info
->kqext_kev
.ext
[3]);
586 printf("%#10lx ", (unsigned long)info
->kqext_kev
.xflags
);
595 printf(" ***** output truncated (>=%i knotes on kq %" PRIu64
", proc %i) *****\n",
609 pid_kqids(pid_t pid
, kqueue_id_t
**kqids_out
)
611 static int kqids_len
= 256;
612 static kqueue_id_t
*kqids
= NULL
;
613 static uint32_t kqids_size
;
618 if (os_mul_overflow(sizeof(kqueue_id_t
), kqids_len
, &kqids_size
)) {
619 assert(kqids_len
> PROC_PIDDYNKQUEUES_MAX
);
620 kqids_len
= PROC_PIDDYNKQUEUES_MAX
;
624 kqids
= malloc(kqids_size
);
625 os_assert(kqids
!= NULL
);
628 nkqids
= proc_list_dynkqueueids(pid
, kqids
, kqids_size
);
629 if (nkqids
> kqids_len
&& kqids_len
< PROC_PIDDYNKQUEUES_MAX
) {
631 if (kqids_len
> PROC_PIDDYNKQUEUES_MAX
) {
632 kqids_len
= PROC_PIDDYNKQUEUES_MAX
;
640 return MIN(nkqids
, kqids_len
);
644 process_pid(pid_t pid
)
649 int maxfds
= 256; /* arbitrary starting point */
650 struct proc_fdinfo
*fdlist
= NULL
;
652 /* enumerate file descriptors */
655 fdlist
= malloc(sizeof(struct proc_fdinfo
) * maxfds
);
659 perror("failed to allocate");
663 nfds
= proc_pidinfo(pid
, PROC_PIDLISTFDS
, 0, fdlist
,
664 sizeof(struct proc_fdinfo
) * maxfds
);
667 fprintf(stderr
, "%s: failed enumerating file descriptors of process %i: %s",
668 self
, pid
, strerror(ret
));
669 if (ret
== EPERM
&& geteuid() != 0) {
670 fprintf(stderr
, " (are you root?)");
672 fprintf(stderr
, "\n");
676 nfds
/= sizeof(struct proc_fdinfo
);
677 if (nfds
>= maxfds
) {
684 /* get bsdinfo for the process name */
685 struct proc_bsdinfo bsdinfo
;
686 ret
= proc_pidinfo(pid
, PROC_PIDTBSDINFO
, 0, &bsdinfo
, sizeof(bsdinfo
));
687 if (ret
!= sizeof(bsdinfo
)) {
688 perror("failed retrieving process info");
693 char *procname
= bsdinfo
.pbi_name
;
694 if (strlen(procname
) == 0) {
695 procname
= bsdinfo
.pbi_comm
;
698 /* handle the special workq kq */
699 ret
= process_kqueue(pid
, procname
, KQTYPE_FD
, -1, fdlist
, nfds
);
704 for (i
= 0; i
< nfds
; i
++) {
705 if (fdlist
[i
].proc_fdtype
== PROX_FDTYPE_KQUEUE
) {
706 ret
= process_kqueue(pid
, procname
, KQTYPE_FD
,
707 (uint64_t)fdlist
[i
].proc_fd
, fdlist
, nfds
);
714 nkqids
= pid_kqids(pid
, &kqids
);
716 for (i
= 0; i
< nkqids
; i
++) {
717 ret
= process_kqueue(pid
, procname
, KQTYPE_DYNAMIC
, kqids
[i
], fdlist
, nfds
);
723 if (nkqids
>= PROC_PIDDYNKQUEUES_MAX
) {
724 printf(" ***** output truncated (>=%i dynamic kqueues in proc %i) *****\n",
738 process_all_pids(void)
747 pids
= malloc(sizeof(int) * maxpids
);
750 perror("failed allocating pids[]");
755 npids
= proc_listpids(PROC_ALL_PIDS
, 0, pids
, sizeof(int) * maxpids
);
759 } else if (errno
== EAGAIN
) {
763 perror("failed enumerating pids");
768 npids
/= sizeof(int);
769 if (npids
>= maxpids
) {
770 maxpids
= npids
+ 16;
776 for (i
= 0; i
< npids
; i
++) {
777 /* listpids gives us pid 0 for some reason */
779 ret
= process_pid(pids
[i
]);
780 /* ignore races with processes exiting */
781 if (ret
&& ret
!= ESRCH
) {
799 fprintf(stderr
, "\nFilter-independent flags:\n\n\
801 command pid kq kqst knid filter fdtype fflags flags evst qos\033[0m\n\033[1m\
802 -------------------- ----- ------------------ ---- ------------------ --------- -------- ------- --------------- ----------------- ---\033[0m\n\
803 ┌ EV_UDATA_SPECIFIC\n\
804 EV_DISPATCH ┐ │┌ EV_FLAG0 (EV_POLL)\n\
805 EV_CLEAR ┐│ ││┌ EV_FLAG1 (EV_OOBAND)\n\
806 EV_ONESHOT ┐││ │││┌ EV_EOF\n\
807 EV_RECEIPT ┐│││ ││││┌ EV_ERROR\n\
809 launchd 1 4 ks- netbiosd 250 PROC ------- andx r1cs upboe aqds dwca supt vn IN\033[0m \n\
810 │ │││ ││││ ││││ ││││ ││││ ││\n\
811 kqueue file descriptor/dynamic ID ┘ │││ EV_ADD ┘│││ KN_ACTIVE ┘│││ ││││ ││││ ││\n\
812 KQ_SLEEP ┘││ EV_ENABLE ┘││ KN_QUEUED ┘││ ││││ ││││ ││\n\
813 KQ_SEL ┘│ EV_DISABLE ┘│ KN_DISABLED ┘│ ││││ ││││ │└ KN_VANISHED\n\
814 KQ_WORKQ (q) ┤ EV_DELETE ┘ KN_STAYACTIVE ┘ ││││ ││││ └ KN_REQVANISH\n\
815 KQ_WORKLOOP (l) ┘ ││││ ││││\n\
816 KN_DROPPING ┘│││ │││└ KN_STOLENDROP\n\
817 KN_USEWAIT ┘││ ││└ KN_SUPPRESSED\n\
818 KN_ATTACHING ┘│ │└ KN_UDATA_SPECIFIC\n\
819 KN_ATTACHED ┘ └ KN_DISPATCH\n\
826 fprintf(stderr
, "usage: %s [-vher] [-a | -p <pid>]\n", self
);
833 printf(" pid kq kqst knid filter fflags flags evst qos data");
835 printf("command pid kq kqst knid filter fdtype fflags flags evst qos data");
839 printf(" udata servicer / ext0 owner / ext1 ext2 ext3 xflags");
845 printf("----- ------------------ ---------- ------------------ --------- ---------- ---------- ---------- --- ------------------");
847 printf("-------------------- ----- ------------------ ---- ------------------ --------- -------- ------- --------------- ----------------- --- ------------------");
851 printf(" ------------------ ------------------ ------------------ ------------------ ------------------ ----------");
857 main(int argc
, char *argv
[])
868 while ((opt
= getopt(argc
, argv
, "eahvrp:")) != -1) {
900 /* also allow lskq <pid> */
901 if (pid
|| all_pids
) {
907 } else if (argc
> 1) {
912 /* exactly one of -p or -a is required */
913 if (!pid
&& !all_pids
) {
916 } else if (pid
&& all_pids
) {
924 return process_all_pids();
926 return process_pid(pid
);