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%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' : '-',
112 (ff
& NOTE_FUNLOCK
) ? 'u' : '-'
118 /* NOTE_REAP is deprecated, but we still want to show if it's used */
119 #pragma clang diagnostic push
120 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
121 snprintf(str
, len
, "%c%c%c%c%c%c%c",
122 (ff
& NOTE_EXIT
) ? 'x' : '-',
123 (ff
& NOTE_EXITSTATUS
) ? 't' : '-',
124 (ff
& NOTE_EXIT_DETAIL
)? 'd' : '-',
125 (ff
& NOTE_FORK
) ? 'f' : '-',
126 (ff
& NOTE_EXEC
) ? 'e' : '-',
127 (ff
& NOTE_SIGNAL
) ? 's' : '-',
128 (ff
& NOTE_REAP
) ? 'r' : '-'
131 #pragma clang diagnostic pop
135 snprintf(str
, len
, "%c%c%c%c%c ",
136 (ff
& NOTE_SECONDS
) ? 's' :
137 (ff
& NOTE_USECONDS
) ? 'u' :
138 (ff
& NOTE_NSECONDS
) ? 'n' :
139 (ff
& NOTE_MACHTIME
) ? 'm' : '?',
140 (ff
& NOTE_ABSOLUTE
) ? 'a' :
141 (ff
& NOTE_MACH_CONTINUOUS_TIME
) ? 'A' : '-',
142 (ff
& NOTE_CRITICAL
) ? 'c' : '-',
143 (ff
& NOTE_BACKGROUND
) ? 'b' : '-',
144 (ff
& NOTE_LEEWAY
) ? 'l' : '-'
150 snprintf(str
, len
, "%c%c%c ",
151 (ff
& NOTE_TRIGGER
) ? 't' : '-',
152 (ff
& NOTE_FFAND
) ? 'a' : '-',
153 (ff
& NOTE_FFOR
) ? 'o' : '-'
157 case EVFILT_WORKLOOP
:
158 snprintf(str
, len
, "%c%c%c%c%c ",
159 (ff
& NOTE_WL_THREAD_REQUEST
) ? 't' :
160 (ff
& NOTE_WL_SYNC_WAIT
) ? 'w' :
161 (ff
& NOTE_WL_SYNC_IPC
) ? 'i' : '-',
162 (ff
& NOTE_WL_SYNC_WAKE
) ? 'W' : '-',
163 (ff
& NOTE_WL_UPDATE_QOS
) ? 'q' : '-',
164 (ff
& NOTE_WL_DISCOVER_OWNER
) ? 'o' : '-',
165 (ff
& NOTE_WL_IGNORE_ESTALE
) ? 'e' : '-'
170 snprintf(str
, len
, "");
179 filter_is_fd_type(int filter
)
182 case EVFILT_VNODE
... EVFILT_READ
:
184 case EVFILT_NW_CHANNEL
:
192 thread_qos_name(uint8_t th_qos
)
203 default: return "??";
208 * find index of fd in a list of fdinfo of length nfds
211 fd_list_getfd(struct proc_fdinfo
*fds
, int nfds
, int fd
)
214 for (i
= 0; i
< nfds
; i
++) {
215 if (fds
[i
].proc_fd
== fd
) {
224 * left truncate URL-form process names
227 shorten_procname(const char *proc
, int width
)
229 if (strcasestr(proc
, "com.") == proc
) {
230 long len
= strlen(proc
);
232 return &proc
[len
- width
];
242 * stringify knote ident where possible (signals, processes)
245 print_ident(uint64_t ident
, int16_t filter
, int width
)
248 printf("%#*llx ", width
, ident
);
259 int numlen
= sprintf(num
, "%llu", ident
);
260 int strwidth
= width
- numlen
- 1; // add room for a space
262 if (filter
== EVFILT_SIGNAL
) {
263 if (ident
< ARRAYLEN(sig_strs
)) {
264 snprintf(str
, strwidth
+ 1, "%s", sig_strs
[ident
]);
267 /* FIXME: this should be cached */
268 struct proc_bsdinfo bsdinfo
;
269 int ret
= proc_pidinfo((int)ident
, PROC_PIDTBSDINFO
, 0, &bsdinfo
, sizeof(bsdinfo
));
270 if (ret
== sizeof(bsdinfo
)) {
271 char *procname
= bsdinfo
.pbi_name
;
272 if (strlen(procname
) == 0) {
273 procname
= bsdinfo
.pbi_comm
;
275 snprintf(str
, strwidth
+ 1, "%s", shorten_procname(procname
, strwidth
));
279 if (str
[0] != '\0') {
280 snprintf(out
, width
+ 1, "%-*s %s", strwidth
, str
, num
);
282 snprintf(out
, width
+ 1, "%s", num
);
285 printf("%*s ", width
, out
);
289 case EVFILT_MACHPORT
:
291 /* hex, to match lsmp */
292 printf("%#*llx ", width
, ident
);
295 case EVFILT_WORKLOOP
:
296 printf("%#*llx ", width
, ident
);
300 printf("%*llu ", width
, ident
);
307 print_kqid(int state
, uint64_t kqid
)
309 if (state
& KQ_WORKQ
) {
310 printf("%18s ", "wq");
311 } else if (state
& KQ_WORKLOOP
) {
312 printf("%#18" PRIx64
" ", kqid
);
314 printf("fd %15" PRIi64
" ", kqid
);
318 #define PROCNAME_WIDTH 20
321 print_kq_info(int pid
, const char *procname
, uint64_t kqid
, int state
)
325 print_kqid(state
, kqid
);
326 printf("%#10x ", state
);
328 char tmpstr
[PROCNAME_WIDTH
+1];
329 strlcpy(tmpstr
, shorten_procname(procname
, PROCNAME_WIDTH
), PROCNAME_WIDTH
+1);
330 printf("%-*s ", PROCNAME_WIDTH
, tmpstr
);
332 print_kqid(state
, kqid
);
334 (state
& KQ_SLEEP
) ? 'k' : '-',
335 (state
& KQ_SEL
) ? 's' : '-',
336 (state
& KQ_WORKQ
) ? 'q' :
337 (state
& KQ_WORKLOOP
) ? 'l' : '-'
347 #define POLICY_TIMESHARE 1
349 #define POLICY_FIFO 4
352 process_kqueue(int pid
, const char *procname
, enum kqtype type
, uint64_t kqid
,
353 struct proc_fdinfo
*fdlist
, int nfds
)
357 int maxknotes
= 256; /* arbitrary starting point */
359 bool is_kev_64
, is_kev_qos
;
361 bool overflow
= false;
363 bool dynkq_printed
= false;
366 * get the basic kqueue info
368 struct kqueue_fdinfo kqfdinfo
= {};
369 struct kqueue_dyninfo kqinfo
= {};
372 ret
= proc_pidfdinfo(pid
, (int)kqid
, PROC_PIDFDKQUEUEINFO
, &kqfdinfo
, sizeof(kqfdinfo
));
376 ret
= proc_piddynkqueueinfo(pid
, PROC_PIDDYNKQUEUE_INFO
, kqid
, &kqinfo
, sizeof(kqinfo
));
379 os_crash("invalid kqueue type");
382 if (type
== KQTYPE_FD
&& (int)kqid
!= -1) {
383 if (ret
!= sizeof(kqfdinfo
)) {
384 /* every proc has an implicit workq kqueue, dont warn if its unused */
385 fprintf(stderr
, "WARN: FD table changed (pid %i, kq %i)\n", pid
,
388 } else if (type
== KQTYPE_DYNAMIC
) {
389 if (ret
< sizeof(struct kqueue_info
)) {
390 fprintf(stderr
, "WARN: kqueue missing (pid %i, kq %#" PRIx64
")\n",
393 kqfdinfo
.kqueueinfo
= kqinfo
.kqdi_info
;
395 if (verbose
&& ret
>= sizeof(struct kqueue_dyninfo
)) {
396 print_kq_info(pid
, procname
, kqid
, kqinfo
.kqdi_info
.kq_state
);
398 if (kqinfo
.kqdi_owner
) {
399 printf("%#18llx ", kqinfo
.kqdi_owner
); // ident
400 printf("%-9s ", "WL owned"); // filter
401 } else if (kqinfo
.kqdi_servicer
) {
402 printf("%#18llx ", kqinfo
.kqdi_servicer
); // ident
403 printf("%-9s ", "WL"); // filter
405 printf("%18s ", "-"); // ident
406 printf("%-9s ", "WL"); // filter
408 dynkq_printed
= true;
411 printf("%-10s ", " "); // fflags
412 printf("%-10s ", " "); // flags
413 printf("%-10s ", " "); // evst
415 const char *reqstate
= "???";
417 switch (kqinfo
.kqdi_request_state
) {
418 case WORKQ_TR_STATE_IDLE
:
421 case WORKQ_TR_STATE_NEW
:
424 case WORKQ_TR_STATE_QUEUED
:
427 case WORKQ_TR_STATE_CANCELED
:
428 reqstate
= "canceled";
430 case WORKQ_TR_STATE_BINDING
:
431 reqstate
= "binding";
433 case WORKQ_TR_STATE_BOUND
:
438 printf("%-8s ", reqstate
); // fdtype
440 switch (kqinfo
.kqdi_pol
) {
446 case POLICY_TIMESHARE
:
452 snprintf(tmpstr
, 4, "%c%c%c", (kqinfo
.kqdi_pri
== 0)?'-':'P', policy_type
, (kqinfo
.kqdi_cpupercent
== 0)?'-':'%');
453 printf("%-7s ", tmpstr
); // fflags
454 printf("%-15s ", " "); // flags
455 printf("%-15s ", " "); // evst
458 if (!raw
&& kqinfo
.kqdi_pri
!= 0) {
459 printf("%3d ", kqinfo
.kqdi_pri
); //qos
461 int qos
= MAX(MAX(kqinfo
.kqdi_events_qos
, kqinfo
.kqdi_async_qos
),
462 kqinfo
.kqdi_sync_waiter_qos
);
463 printf("%3s ", thread_qos_name(qos
)); //qos
470 * get extended kqueue info
472 struct kevent_extinfo
*kqextinfo
= NULL
;
475 kqextinfo
= malloc(sizeof(struct kevent_extinfo
) * maxknotes
);
479 perror("failed allocating memory");
486 nknotes
= proc_pidfdinfo(pid
, fd
, PROC_PIDFDKQUEUE_EXTINFO
,
487 kqextinfo
, sizeof(struct kevent_extinfo
) * maxknotes
);
490 nknotes
= proc_piddynkqueueinfo(pid
, PROC_PIDDYNKQUEUE_EXTINFO
, kqid
,
491 kqextinfo
, sizeof(struct kevent_extinfo
) * maxknotes
);
494 os_crash("invalid kqueue type");
499 /* proc_*() can't distinguish between error and empty list */
500 } else if (errno
== EAGAIN
) {
502 } else if (errno
== EBADF
) {
503 fprintf(stderr
, "WARN: FD table changed (pid %i, kq %#" PRIx64
")\n", pid
, kqid
);
507 perror("failed to get extended kqueue info");
512 if (nknotes
> maxknotes
) {
513 maxknotes
= nknotes
+ 16; /* arbitrary safety margin */
519 if (nknotes
>= PROC_PIDFDKQUEUE_KNOTES_MAX
) {
523 kq_state
= kqfdinfo
.kqueueinfo
.kq_state
;
524 is_kev_64
= (kq_state
& PROC_KQUEUE_64
);
525 is_kev_qos
= (kq_state
& PROC_KQUEUE_QOS
);
528 if (!ignore_empty
&& !dynkq_printed
) {
529 /* for empty kqueues, print a single empty entry */
530 print_kq_info(pid
, procname
, kqid
, kq_state
);
531 printf("%18s \n", "-");
536 for (i
= 0; i
< nknotes
; i
++) {
537 struct kevent_extinfo
*info
= &kqextinfo
[i
];
539 print_kq_info(pid
, procname
, kqid
, kqfdinfo
.kqueueinfo
.kq_state
);
540 print_ident(info
->kqext_kev
.ident
, info
->kqext_kev
.filter
, 18);
541 printf("%-9s ", filt_name(info
->kqext_kev
.filter
));
544 printf("%#10x ", info
->kqext_sfflags
);
545 printf("%#10x ", info
->kqext_kev
.flags
);
546 printf("%#10x ", info
->kqext_status
);
548 /* for kevents attached to file descriptors, print the type of FD (file, socket, etc) */
549 const char *fdstr
= "";
550 if (filter_is_fd_type(info
->kqext_kev
.filter
)) {
552 int knfd
= fd_list_getfd(fdlist
, nfds
, (int)info
->kqext_kev
.ident
);
554 fdstr
= fdtype_str(fdlist
[knfd
].proc_fdtype
);
557 printf("%-8s ", fdstr
);
559 /* print filter flags */
560 printf("%7s ", fflags_build(info
, tmpstr
, sizeof(tmpstr
)));
562 /* print generic flags */
563 unsigned flg
= info
->kqext_kev
.flags
;
564 printf("%c%c%c%c %c%c%c%c %c%c%c%c%c ",
565 (flg
& EV_ADD
) ? 'a' : '-',
566 (flg
& EV_ENABLE
) ? 'n' : '-',
567 (flg
& EV_DISABLE
) ? 'd' : '-',
568 (flg
& EV_DELETE
) ? 'x' : '-',
570 (flg
& EV_RECEIPT
) ? 'r' : '-',
571 (flg
& EV_ONESHOT
) ? '1' : '-',
572 (flg
& EV_CLEAR
) ? 'c' : '-',
573 (flg
& EV_DISPATCH
) ? 's' : '-',
575 (flg
& EV_UDATA_SPECIFIC
) ? 'u' : '-',
576 (flg
& EV_FLAG0
) ? 'p' : '-',
577 (flg
& EV_FLAG1
) ? 'b' : '-',
578 (flg
& EV_EOF
) ? 'o' : '-',
579 (flg
& EV_ERROR
) ? 'e' : '-'
582 unsigned st
= info
->kqext_status
;
583 printf("%c%c%c%c%c %c%c%c%c %c%c%c ",
584 (st
& KN_ACTIVE
) ? 'a' : '-',
585 (st
& KN_QUEUED
) ? 'q' : '-',
586 (st
& KN_DISABLED
) ? 'd' : '-',
587 (st
& KN_SUPPRESSED
) ? 'p' : '-',
588 (st
& KN_STAYACTIVE
) ? 's' : '-',
590 (st
& KN_DROPPING
) ? 'd' : '-',
591 (st
& KN_LOCKED
) ? 'l' : '-',
592 (st
& KN_POSTING
) ? 'P' : '-',
593 (st
& KN_MERGE_QOS
) ? 'm' : '-',
595 (st
& KN_DEFERDELETE
) ? 'D' : '-',
596 (st
& KN_REQVANISH
) ? 'v' : '-',
597 (st
& KN_VANISHED
) ? 'n' : '-'
601 printf("%3s ", thread_qos_name(info
->kqext_kev
.qos
));
603 printf("%#18llx ", (unsigned long long)info
->kqext_kev
.data
);
606 printf("%#18llx ", (unsigned long long)info
->kqext_kev
.udata
);
607 if (is_kev_qos
|| is_kev_64
) {
608 printf("%#18llx ", (unsigned long long)info
->kqext_kev
.ext
[0]);
609 printf("%#18llx ", (unsigned long long)info
->kqext_kev
.ext
[1]);
612 printf("%#18llx ", (unsigned long long)info
->kqext_kev
.ext
[2]);
613 printf("%#18llx ", (unsigned long long)info
->kqext_kev
.ext
[3]);
614 printf("%#10lx ", (unsigned long)info
->kqext_kev
.xflags
);
623 printf(" ***** output truncated (>=%i knotes on kq %" PRIu64
", proc %i) *****\n",
637 pid_kqids(pid_t pid
, kqueue_id_t
**kqids_out
)
639 static int kqids_len
= 256;
640 static kqueue_id_t
*kqids
= NULL
;
641 static uint32_t kqids_size
;
646 if (os_mul_overflow(sizeof(kqueue_id_t
), kqids_len
, &kqids_size
)) {
647 assert(kqids_len
> PROC_PIDDYNKQUEUES_MAX
);
648 kqids_len
= PROC_PIDDYNKQUEUES_MAX
;
652 kqids
= malloc(kqids_size
);
653 os_assert(kqids
!= NULL
);
656 nkqids
= proc_list_dynkqueueids(pid
, kqids
, kqids_size
);
657 if (nkqids
> kqids_len
&& kqids_len
< PROC_PIDDYNKQUEUES_MAX
) {
659 if (kqids_len
> PROC_PIDDYNKQUEUES_MAX
) {
660 kqids_len
= PROC_PIDDYNKQUEUES_MAX
;
668 return MIN(nkqids
, kqids_len
);
672 process_pid(pid_t pid
)
677 int maxfds
= 256; /* arbitrary starting point */
678 struct proc_fdinfo
*fdlist
= NULL
;
680 /* enumerate file descriptors */
683 fdlist
= malloc(sizeof(struct proc_fdinfo
) * maxfds
);
687 perror("failed to allocate");
691 nfds
= proc_pidinfo(pid
, PROC_PIDLISTFDS
, 0, fdlist
,
692 sizeof(struct proc_fdinfo
) * maxfds
);
695 fprintf(stderr
, "%s: failed enumerating file descriptors of process %i: %s",
696 self
, pid
, strerror(ret
));
697 if (ret
== EPERM
&& geteuid() != 0) {
698 fprintf(stderr
, " (are you root?)");
700 fprintf(stderr
, "\n");
704 nfds
/= sizeof(struct proc_fdinfo
);
705 if (nfds
>= maxfds
) {
712 /* get bsdinfo for the process name */
713 struct proc_bsdinfo bsdinfo
;
714 ret
= proc_pidinfo(pid
, PROC_PIDTBSDINFO
, 0, &bsdinfo
, sizeof(bsdinfo
));
715 if (ret
!= sizeof(bsdinfo
)) {
716 perror("failed retrieving process info");
721 char *procname
= bsdinfo
.pbi_name
;
722 if (strlen(procname
) == 0) {
723 procname
= bsdinfo
.pbi_comm
;
726 /* handle the special workq kq */
727 ret
= process_kqueue(pid
, procname
, KQTYPE_FD
, -1, fdlist
, nfds
);
732 for (i
= 0; i
< nfds
; i
++) {
733 if (fdlist
[i
].proc_fdtype
== PROX_FDTYPE_KQUEUE
) {
734 ret
= process_kqueue(pid
, procname
, KQTYPE_FD
,
735 (uint64_t)fdlist
[i
].proc_fd
, fdlist
, nfds
);
742 nkqids
= pid_kqids(pid
, &kqids
);
744 for (i
= 0; i
< nkqids
; i
++) {
745 ret
= process_kqueue(pid
, procname
, KQTYPE_DYNAMIC
, kqids
[i
], fdlist
, nfds
);
751 if (nkqids
>= PROC_PIDDYNKQUEUES_MAX
) {
752 printf(" ***** output truncated (>=%i dynamic kqueues in proc %i) *****\n",
766 process_all_pids(void)
775 pids
= malloc(sizeof(int) * maxpids
);
778 perror("failed allocating pids[]");
783 npids
= proc_listpids(PROC_ALL_PIDS
, 0, pids
, sizeof(int) * maxpids
);
787 } else if (errno
== EAGAIN
) {
791 perror("failed enumerating pids");
796 npids
/= sizeof(int);
797 if (npids
>= maxpids
) {
798 maxpids
= npids
+ 16;
804 for (i
= 0; i
< npids
; i
++) {
805 /* listpids gives us pid 0 for some reason */
807 ret
= process_pid(pids
[i
]);
808 /* ignore races with processes exiting */
809 if (ret
&& ret
!= ESRCH
) {
827 const char *bold
= "\033[1m";
828 const char *reset
= "\033[0m";
829 if (!isatty(STDERR_FILENO
)) {
833 fprintf(stderr
, "\nFilter-independent flags:\n\n\
835 command pid kq kqst knid filter fdtype fflags flags evst qos%s\n%s\
836 -------------------- ----- ------------------ ---- ------------------ --------- -------- ------- --------------- -------------- ---%s\n\
837 ┌ EV_UDATA_SPECIFIC\n\
838 EV_DISPATCH ┐ │┌ EV_FLAG0 (EV_POLL)\n\
839 EV_CLEAR ┐│ ││┌ EV_FLAG1 (EV_OOBAND)\n\
840 EV_ONESHOT ┐││ │││┌ EV_EOF\n\
841 EV_RECEIPT ┐│││ ││││┌ EV_ERROR\n\
843 launchd 1 4 ks- netbiosd 250 PROC ------- andx r1cs upboe aqdps dlPm Dvn IN%s\n\
844 │ │││ ││││ │││││ ││││ │││\n\
845 kqueue file descriptor/dynamic ID ┘ │││ EV_ADD ┘│││ KN_ACTIVE ┘││││ ││││ ││└ KN_VANISHED\n\
846 KQ_SLEEP ┘││ EV_ENABLE ┘││ KN_QUEUED ┘│││ ││││ │└ KN_REQVANISH\n\
847 KQ_SEL ┘│ EV_DISABLE ┘│ KN_DISABLED ┘││ ││││ └ KN_DEFERDELETE\n\
848 KQ_WORKQ (q) ┤ EV_DELETE ┘ KN_SUPPRESSED ┘│ ││││\n\
849 KQ_WORKLOOP (l) ┘ KN_STAYACTIVE ┘ ││││\n\
851 KN_DROPPING ┘││└ KN_MERGE_QOS\n\
852 KN_LOCKED ┘└ KN_POSTING\n\
853 \n", bold
, reset
, bold
, reset
, bold
, reset
);
859 fprintf(stderr
, "usage: %s [-vher] [-a | -p <pid>]\n", self
);
866 printf(" pid kq kqst knid filter fflags flags evst qos data");
868 printf("command pid kq kqst knid filter fdtype fflags flags evst qos data");
872 printf(" udata ext0 ext1 ext2 ext3 xflags");
878 printf("----- ------------------ ---------- ------------------ --------- ---------- ---------- ---------- --- ------------------");
880 printf("-------------------- ----- ------------------ ---- ------------------ --------- -------- ------- --------------- -------------- --- ------------------");
884 printf(" ------------------ ------------------ ------------------ ------------------ ------------------ ----------");
890 main(int argc
, char *argv
[])
901 while ((opt
= getopt(argc
, argv
, "eahvrp:")) != -1) {
933 /* also allow lskq <pid> */
934 if (pid
|| all_pids
) {
940 } else if (argc
> 1) {
945 /* exactly one of -p or -a is required */
946 if (!pid
&& !all_pids
) {
949 } else if (pid
&& all_pids
) {
957 return process_all_pids();
959 return process_pid(pid
);