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>
40 #include <os/assumes.h>
41 #include <os/overflow.h>
45 #define ARRAYLEN(x) (sizeof((x))/sizeof((x[0])))
47 /* command line options */
50 static int ignore_empty
;
53 static char *self
= "lskq";
55 static inline const char *
56 filt_name(int16_t filt
)
58 static char unkn_filt
[32];
60 if (idx
>= 0 && idx
< ARRAYLEN(filt_strs
)) {
61 return filt_strs
[idx
];
63 snprintf(unkn_filt
, sizeof(unkn_filt
), "%i (?)", idx
);
68 static inline const char *
69 fdtype_str(uint32_t type
)
71 static char unkn_fdtype
[32];
72 if (type
< ARRAYLEN(fdtype_strs
)) {
73 return fdtype_strs
[type
];
75 snprintf(unkn_fdtype
, sizeof(unkn_fdtype
), "%i (?)", type
);
81 fflags_build(struct kevent_extinfo
*info
, char *str
, int len
)
83 unsigned ff
= info
->kqext_sfflags
;
85 switch (info
->kqext_kev
.filter
) {
88 snprintf(str
, len
, "%c ",
89 (ff
& NOTE_LOWAT
) ? 'l' : '-'
94 case EVFILT_MACHPORT
: {
95 snprintf(str
, len
, "%c ",
96 (ff
& MACH_RCV_MSG
) ? 'r' : '-'
102 snprintf(str
, len
, "%c%c%c%c%c%c%c%c",
103 (ff
& NOTE_DELETE
) ? 'd' : '-',
104 (ff
& NOTE_WRITE
) ? 'w' : '-',
105 (ff
& NOTE_EXTEND
) ? 'e' : '-',
106 (ff
& NOTE_ATTRIB
) ? 'a' : '-',
107 (ff
& NOTE_LINK
) ? 'l' : '-',
108 (ff
& NOTE_RENAME
) ? 'r' : '-',
109 (ff
& NOTE_REVOKE
) ? 'v' : '-',
110 (ff
& NOTE_FUNLOCK
) ? 'u' : '-'
116 /* NOTE_REAP is deprecated, but we still want to show if it's used */
117 #pragma clang diagnostic push
118 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
119 snprintf(str
, len
, "%c%c%c%c%c%c%c",
120 (ff
& NOTE_EXIT
) ? 'x' : '-',
121 (ff
& NOTE_EXITSTATUS
) ? 't' : '-',
122 (ff
& NOTE_EXIT_DETAIL
)? 'd' : '-',
123 (ff
& NOTE_FORK
) ? 'f' : '-',
124 (ff
& NOTE_EXEC
) ? 'e' : '-',
125 (ff
& NOTE_SIGNAL
) ? 's' : '-',
126 (ff
& NOTE_REAP
) ? 'r' : '-'
129 #pragma clang diagnostic pop
133 snprintf(str
, len
, "%c%c%c%c%c ",
134 (ff
& NOTE_SECONDS
) ? 's' :
135 (ff
& NOTE_USECONDS
) ? 'u' :
136 (ff
& NOTE_NSECONDS
) ? 'n' :
137 (ff
& NOTE_MACHTIME
) ? 'm' : '?',
138 (ff
& NOTE_ABSOLUTE
) ? 'a' :
139 (ff
& NOTE_MACH_CONTINUOUS_TIME
) ? 'A' : '-',
140 (ff
& NOTE_CRITICAL
) ? 'c' : '-',
141 (ff
& NOTE_BACKGROUND
) ? 'b' : '-',
142 (ff
& NOTE_LEEWAY
) ? 'l' : '-'
148 snprintf(str
, len
, "%c%c%c ",
149 (ff
& NOTE_TRIGGER
) ? 't' : '-',
150 (ff
& NOTE_FFAND
) ? 'a' : '-',
151 (ff
& NOTE_FFOR
) ? 'o' : '-'
155 case EVFILT_WORKLOOP
:
156 snprintf(str
, len
, "%c%c%c%c%c ",
157 (ff
& NOTE_WL_THREAD_REQUEST
) ? 't' :
158 (ff
& NOTE_WL_SYNC_WAIT
) ? 'w' :
159 (ff
& NOTE_WL_SYNC_IPC
) ? 'i' : '-',
160 (ff
& NOTE_WL_SYNC_WAKE
) ? 'W' : '-',
161 (ff
& NOTE_WL_UPDATE_QOS
) ? 'q' : '-',
162 (ff
& NOTE_WL_DISCOVER_OWNER
) ? 'o' : '-',
163 (ff
& NOTE_WL_IGNORE_ESTALE
) ? 'e' : '-'
168 snprintf(str
, len
, "");
177 filter_is_fd_type(int filter
)
180 case EVFILT_VNODE
... EVFILT_READ
:
189 thread_qos_name(uint8_t th_qos
)
200 default: return "??";
205 * find index of fd in a list of fdinfo of length nfds
208 fd_list_getfd(struct proc_fdinfo
*fds
, int nfds
, int fd
)
211 for (i
= 0; i
< nfds
; i
++) {
212 if (fds
[i
].proc_fd
== fd
) {
221 * left truncate URL-form process names
224 shorten_procname(const char *proc
, int width
)
226 if (strcasestr(proc
, "com.") == proc
) {
227 long len
= strlen(proc
);
229 return &proc
[len
- width
];
239 * stringify knote ident where possible (signals, processes)
242 print_ident(uint64_t ident
, int16_t filter
, int width
)
245 printf("%#*llx ", width
, ident
);
256 int numlen
= sprintf(num
, "%llu", ident
);
257 int strwidth
= width
- numlen
- 1; // add room for a space
259 if (filter
== EVFILT_SIGNAL
) {
260 if (ident
< ARRAYLEN(sig_strs
)) {
261 snprintf(str
, strwidth
+ 1, "%s", sig_strs
[ident
]);
264 /* FIXME: this should be cached */
265 struct proc_bsdinfo bsdinfo
;
266 int ret
= proc_pidinfo((int)ident
, PROC_PIDTBSDINFO
, 0, &bsdinfo
, sizeof(bsdinfo
));
267 if (ret
== sizeof(bsdinfo
)) {
268 char *procname
= bsdinfo
.pbi_name
;
269 if (strlen(procname
) == 0) {
270 procname
= bsdinfo
.pbi_comm
;
272 snprintf(str
, strwidth
+ 1, "%s", shorten_procname(procname
, strwidth
));
276 if (str
[0] != '\0') {
277 snprintf(out
, width
+ 1, "%-*s %s", strwidth
, str
, num
);
279 snprintf(out
, width
+ 1, "%s", num
);
282 printf("%*s ", width
, out
);
286 case EVFILT_MACHPORT
:
288 /* hex, to match lsmp */
289 printf("%#*llx ", width
, ident
);
292 case EVFILT_WORKLOOP
:
293 printf("%#*llx ", width
, ident
);
297 printf("%*llu ", width
, ident
);
304 print_kqid(int state
, uint64_t kqid
)
306 if (state
& KQ_WORKQ
) {
307 printf("%18s ", "wq");
308 } else if (state
& KQ_WORKLOOP
) {
309 printf("%#18" PRIx64
" ", kqid
);
311 printf("fd %15" PRIi64
" ", kqid
);
315 #define PROCNAME_WIDTH 20
318 print_kq_info(int pid
, const char *procname
, uint64_t kqid
, int state
)
322 print_kqid(state
, kqid
);
323 printf("%#10x ", state
);
325 char tmpstr
[PROCNAME_WIDTH
+1];
326 strlcpy(tmpstr
, shorten_procname(procname
, PROCNAME_WIDTH
), PROCNAME_WIDTH
+1);
327 printf("%-*s ", PROCNAME_WIDTH
, tmpstr
);
329 print_kqid(state
, kqid
);
331 (state
& KQ_SLEEP
) ? 'k' : '-',
332 (state
& KQ_SEL
) ? 's' : '-',
333 (state
& KQ_WORKQ
) ? 'q' :
334 (state
& KQ_WORKLOOP
) ? 'l' : '-'
344 #define POLICY_TIMESHARE 1
346 #define POLICY_FIFO 4
349 process_kqueue(int pid
, const char *procname
, enum kqtype type
, uint64_t kqid
,
350 struct proc_fdinfo
*fdlist
, int nfds
)
354 int maxknotes
= 256; /* arbitrary starting point */
356 bool is_kev_64
, is_kev_qos
;
358 bool overflow
= false;
360 bool dynkq_printed
= false;
363 * get the basic kqueue info
365 struct kqueue_fdinfo kqfdinfo
= {};
366 struct kqueue_dyninfo kqinfo
= {};
369 ret
= proc_pidfdinfo(pid
, (int)kqid
, PROC_PIDFDKQUEUEINFO
, &kqfdinfo
, sizeof(kqfdinfo
));
373 ret
= proc_piddynkqueueinfo(pid
, PROC_PIDDYNKQUEUE_INFO
, kqid
, &kqinfo
, sizeof(kqinfo
));
376 os_crash("invalid kqueue type");
379 if (type
== KQTYPE_FD
&& (int)kqid
!= -1) {
380 if (ret
!= sizeof(kqfdinfo
)) {
381 /* every proc has an implicit workq kqueue, dont warn if its unused */
382 fprintf(stderr
, "WARN: FD table changed (pid %i, kq %i)\n", pid
,
385 } else if (type
== KQTYPE_DYNAMIC
) {
386 if (ret
< sizeof(struct kqueue_info
)) {
387 fprintf(stderr
, "WARN: kqueue missing (pid %i, kq %#" PRIx64
")\n",
390 kqfdinfo
.kqueueinfo
= kqinfo
.kqdi_info
;
392 if (verbose
&& ret
>= sizeof(struct kqueue_dyninfo
)) {
393 print_kq_info(pid
, procname
, kqid
, kqinfo
.kqdi_info
.kq_state
);
395 if (kqinfo
.kqdi_owner
) {
396 printf("%#18llx ", kqinfo
.kqdi_owner
); // ident
397 printf("%-9s ", "WL owned"); // filter
398 } else if (kqinfo
.kqdi_servicer
) {
399 printf("%#18llx ", kqinfo
.kqdi_servicer
); // ident
400 printf("%-9s ", "WL"); // filter
402 printf("%18s ", "-"); // ident
403 printf("%-9s ", "WL"); // filter
405 dynkq_printed
= true;
408 printf("%-10s ", " "); // fflags
409 printf("%-10s ", " "); // flags
410 printf("%-10s ", " "); // evst
412 const char *reqstate
= "???";
414 switch (kqinfo
.kqdi_request_state
) {
415 case WORKQ_TR_STATE_IDLE
:
418 case WORKQ_TR_STATE_NEW
:
421 case WORKQ_TR_STATE_QUEUED
:
424 case WORKQ_TR_STATE_CANCELED
:
425 reqstate
= "canceled";
427 case WORKQ_TR_STATE_BINDING
:
428 reqstate
= "binding";
430 case WORKQ_TR_STATE_BOUND
:
435 printf("%-8s ", reqstate
); // fdtype
437 switch (kqinfo
.kqdi_pol
) {
443 case POLICY_TIMESHARE
:
449 snprintf(tmpstr
, 4, "%c%c%c", (kqinfo
.kqdi_pri
== 0)?'-':'P', policy_type
, (kqinfo
.kqdi_cpupercent
== 0)?'-':'%');
450 printf("%-7s ", tmpstr
); // fflags
451 printf("%-15s ", " "); // flags
452 printf("%-15s ", " "); // evst
455 if (!raw
&& kqinfo
.kqdi_pri
!= 0) {
456 printf("%3d ", kqinfo
.kqdi_pri
); //qos
458 int qos
= MAX(MAX(kqinfo
.kqdi_events_qos
, kqinfo
.kqdi_async_qos
),
459 kqinfo
.kqdi_sync_waiter_qos
);
460 printf("%3s ", thread_qos_name(qos
)); //qos
467 * get extended kqueue info
469 struct kevent_extinfo
*kqextinfo
= NULL
;
472 kqextinfo
= malloc(sizeof(struct kevent_extinfo
) * maxknotes
);
476 perror("failed allocating memory");
483 nknotes
= proc_pidfdinfo(pid
, fd
, PROC_PIDFDKQUEUE_EXTINFO
,
484 kqextinfo
, sizeof(struct kevent_extinfo
) * maxknotes
);
487 nknotes
= proc_piddynkqueueinfo(pid
, PROC_PIDDYNKQUEUE_EXTINFO
, kqid
,
488 kqextinfo
, sizeof(struct kevent_extinfo
) * maxknotes
);
491 os_crash("invalid kqueue type");
496 /* proc_*() can't distinguish between error and empty list */
497 } else if (errno
== EAGAIN
) {
499 } else if (errno
== EBADF
) {
500 fprintf(stderr
, "WARN: FD table changed (pid %i, kq %#" PRIx64
")\n", pid
, kqid
);
504 perror("failed to get extended kqueue info");
509 if (nknotes
> maxknotes
) {
510 maxknotes
= nknotes
+ 16; /* arbitrary safety margin */
516 if (nknotes
>= PROC_PIDFDKQUEUE_KNOTES_MAX
) {
520 kq_state
= kqfdinfo
.kqueueinfo
.kq_state
;
521 is_kev_64
= (kq_state
& PROC_KQUEUE_64
);
522 is_kev_qos
= (kq_state
& PROC_KQUEUE_QOS
);
525 if (!ignore_empty
&& !dynkq_printed
) {
526 /* for empty kqueues, print a single empty entry */
527 print_kq_info(pid
, procname
, kqid
, kq_state
);
528 printf("%18s \n", "-");
533 for (i
= 0; i
< nknotes
; i
++) {
534 struct kevent_extinfo
*info
= &kqextinfo
[i
];
536 print_kq_info(pid
, procname
, kqid
, kqfdinfo
.kqueueinfo
.kq_state
);
537 print_ident(info
->kqext_kev
.ident
, info
->kqext_kev
.filter
, 18);
538 printf("%-9s ", filt_name(info
->kqext_kev
.filter
));
541 printf("%#10x ", info
->kqext_sfflags
);
542 printf("%#10x ", info
->kqext_kev
.flags
);
543 printf("%#10x ", info
->kqext_status
);
545 /* for kevents attached to file descriptors, print the type of FD (file, socket, etc) */
546 const char *fdstr
= "";
547 if (filter_is_fd_type(info
->kqext_kev
.filter
)) {
549 int knfd
= fd_list_getfd(fdlist
, nfds
, (int)info
->kqext_kev
.ident
);
551 fdstr
= fdtype_str(fdlist
[knfd
].proc_fdtype
);
554 printf("%-8s ", fdstr
);
556 /* print filter flags */
557 printf("%7s ", fflags_build(info
, tmpstr
, sizeof(tmpstr
)));
559 /* print generic flags */
560 unsigned flg
= info
->kqext_kev
.flags
;
561 printf("%c%c%c%c %c%c%c%c %c%c%c%c%c ",
562 (flg
& EV_ADD
) ? 'a' : '-',
563 (flg
& EV_ENABLE
) ? 'n' : '-',
564 (flg
& EV_DISABLE
) ? 'd' : '-',
565 (flg
& EV_DELETE
) ? 'x' : '-',
567 (flg
& EV_RECEIPT
) ? 'r' : '-',
568 (flg
& EV_ONESHOT
) ? '1' : '-',
569 (flg
& EV_CLEAR
) ? 'c' : '-',
570 (flg
& EV_DISPATCH
) ? 's' : '-',
572 (flg
& EV_UDATA_SPECIFIC
) ? 'u' : '-',
573 (flg
& EV_FLAG0
) ? 'p' : '-',
574 (flg
& EV_FLAG1
) ? 'b' : '-',
575 (flg
& EV_EOF
) ? 'o' : '-',
576 (flg
& EV_ERROR
) ? 'e' : '-'
579 unsigned st
= info
->kqext_status
;
580 printf("%c%c%c%c%c %c%c%c%c %c%c%c ",
581 (st
& KN_ACTIVE
) ? 'a' : '-',
582 (st
& KN_QUEUED
) ? 'q' : '-',
583 (st
& KN_DISABLED
) ? 'd' : '-',
584 (st
& KN_SUPPRESSED
) ? 'p' : '-',
585 (st
& KN_STAYACTIVE
) ? 's' : '-',
587 (st
& KN_DROPPING
) ? 'd' : '-',
588 (st
& KN_LOCKED
) ? 'l' : '-',
589 (st
& KN_POSTING
) ? 'P' : '-',
590 (st
& KN_MERGE_QOS
) ? 'm' : '-',
592 (st
& KN_DEFERDELETE
) ? 'D' : '-',
593 (st
& KN_REQVANISH
) ? 'v' : '-',
594 (st
& KN_VANISHED
) ? 'n' : '-'
598 printf("%3s ", thread_qos_name(info
->kqext_kev
.qos
));
600 printf("%#18llx ", (unsigned long long)info
->kqext_kev
.data
);
603 printf("%#18llx ", (unsigned long long)info
->kqext_kev
.udata
);
604 if (is_kev_qos
|| is_kev_64
) {
605 printf("%#18llx ", (unsigned long long)info
->kqext_kev
.ext
[0]);
606 printf("%#18llx ", (unsigned long long)info
->kqext_kev
.ext
[1]);
609 printf("%#18llx ", (unsigned long long)info
->kqext_kev
.ext
[2]);
610 printf("%#18llx ", (unsigned long long)info
->kqext_kev
.ext
[3]);
611 printf("%#10lx ", (unsigned long)info
->kqext_kev
.xflags
);
620 printf(" ***** output truncated (>=%i knotes on kq %" PRIu64
", proc %i) *****\n",
634 pid_kqids(pid_t pid
, kqueue_id_t
**kqids_out
)
636 static int kqids_len
= 256;
637 static kqueue_id_t
*kqids
= NULL
;
638 static uint32_t kqids_size
;
643 if (os_mul_overflow(sizeof(kqueue_id_t
), kqids_len
, &kqids_size
)) {
644 assert(kqids_len
> PROC_PIDDYNKQUEUES_MAX
);
645 kqids_len
= PROC_PIDDYNKQUEUES_MAX
;
649 kqids
= malloc(kqids_size
);
650 os_assert(kqids
!= NULL
);
653 nkqids
= proc_list_dynkqueueids(pid
, kqids
, kqids_size
);
654 if (nkqids
> kqids_len
&& kqids_len
< PROC_PIDDYNKQUEUES_MAX
) {
656 if (kqids_len
> PROC_PIDDYNKQUEUES_MAX
) {
657 kqids_len
= PROC_PIDDYNKQUEUES_MAX
;
665 return MIN(nkqids
, kqids_len
);
669 process_pid(pid_t pid
)
674 int maxfds
= 256; /* arbitrary starting point */
675 struct proc_fdinfo
*fdlist
= NULL
;
677 /* enumerate file descriptors */
680 fdlist
= malloc(sizeof(struct proc_fdinfo
) * maxfds
);
684 perror("failed to allocate");
688 nfds
= proc_pidinfo(pid
, PROC_PIDLISTFDS
, 0, fdlist
,
689 sizeof(struct proc_fdinfo
) * maxfds
);
692 fprintf(stderr
, "%s: failed enumerating file descriptors of process %i: %s",
693 self
, pid
, strerror(ret
));
694 if (ret
== EPERM
&& geteuid() != 0) {
695 fprintf(stderr
, " (are you root?)");
697 fprintf(stderr
, "\n");
701 nfds
/= sizeof(struct proc_fdinfo
);
702 if (nfds
>= maxfds
) {
709 /* get bsdinfo for the process name */
710 struct proc_bsdinfo bsdinfo
;
711 ret
= proc_pidinfo(pid
, PROC_PIDTBSDINFO
, 0, &bsdinfo
, sizeof(bsdinfo
));
712 if (ret
!= sizeof(bsdinfo
)) {
713 perror("failed retrieving process info");
718 char *procname
= bsdinfo
.pbi_name
;
719 if (strlen(procname
) == 0) {
720 procname
= bsdinfo
.pbi_comm
;
723 /* handle the special workq kq */
724 ret
= process_kqueue(pid
, procname
, KQTYPE_FD
, -1, fdlist
, nfds
);
729 for (i
= 0; i
< nfds
; i
++) {
730 if (fdlist
[i
].proc_fdtype
== PROX_FDTYPE_KQUEUE
) {
731 ret
= process_kqueue(pid
, procname
, KQTYPE_FD
,
732 (uint64_t)fdlist
[i
].proc_fd
, fdlist
, nfds
);
739 nkqids
= pid_kqids(pid
, &kqids
);
741 for (i
= 0; i
< nkqids
; i
++) {
742 ret
= process_kqueue(pid
, procname
, KQTYPE_DYNAMIC
, kqids
[i
], fdlist
, nfds
);
748 if (nkqids
>= PROC_PIDDYNKQUEUES_MAX
) {
749 printf(" ***** output truncated (>=%i dynamic kqueues in proc %i) *****\n",
763 process_all_pids(void)
772 pids
= malloc(sizeof(int) * maxpids
);
775 perror("failed allocating pids[]");
780 npids
= proc_listpids(PROC_ALL_PIDS
, 0, pids
, sizeof(int) * maxpids
);
784 } else if (errno
== EAGAIN
) {
788 perror("failed enumerating pids");
793 npids
/= sizeof(int);
794 if (npids
>= maxpids
) {
795 maxpids
= npids
+ 16;
801 for (i
= 0; i
< npids
; i
++) {
802 /* listpids gives us pid 0 for some reason */
804 ret
= process_pid(pids
[i
]);
805 /* ignore races with processes exiting */
806 if (ret
&& ret
!= ESRCH
) {
824 const char *bold
= "\033[1m";
825 const char *reset
= "\033[0m";
826 if (!isatty(STDERR_FILENO
)) {
830 fprintf(stderr
, "\nFilter-independent flags:\n\n\
832 command pid kq kqst knid filter fdtype fflags flags evst qos%s\n%s\
833 -------------------- ----- ------------------ ---- ------------------ --------- -------- ------- --------------- -------------- ---%s\n\
834 ┌ EV_UDATA_SPECIFIC\n\
835 EV_DISPATCH ┐ │┌ EV_FLAG0 (EV_POLL)\n\
836 EV_CLEAR ┐│ ││┌ EV_FLAG1 (EV_OOBAND)\n\
837 EV_ONESHOT ┐││ │││┌ EV_EOF\n\
838 EV_RECEIPT ┐│││ ││││┌ EV_ERROR\n\
840 launchd 1 4 ks- netbiosd 250 PROC ------- andx r1cs upboe aqdps dlPm Dvn IN%s\n\
841 │ │││ ││││ │││││ ││││ │││\n\
842 kqueue file descriptor/dynamic ID ┘ │││ EV_ADD ┘│││ KN_ACTIVE ┘││││ ││││ ││└ KN_VANISHED\n\
843 KQ_SLEEP ┘││ EV_ENABLE ┘││ KN_QUEUED ┘│││ ││││ │└ KN_REQVANISH\n\
844 KQ_SEL ┘│ EV_DISABLE ┘│ KN_DISABLED ┘││ ││││ └ KN_DEFERDELETE\n\
845 KQ_WORKQ (q) ┤ EV_DELETE ┘ KN_SUPPRESSED ┘│ ││││\n\
846 KQ_WORKLOOP (l) ┘ KN_STAYACTIVE ┘ ││││\n\
848 KN_DROPPING ┘││└ KN_MERGE_QOS\n\
849 KN_LOCKED ┘└ KN_POSTING\n\
850 \n", bold
, reset
, bold
, reset
, bold
, reset
);
856 fprintf(stderr
, "usage: %s [-vher] [-a | -p <pid>]\n", self
);
863 printf(" pid kq kqst knid filter fflags flags evst qos data");
865 printf("command pid kq kqst knid filter fdtype fflags flags evst qos data");
869 printf(" udata ext0 ext1 ext2 ext3 xflags");
875 printf("----- ------------------ ---------- ------------------ --------- ---------- ---------- ---------- --- ------------------");
877 printf("-------------------- ----- ------------------ ---- ------------------ --------- -------- ------- --------------- -------------- --- ------------------");
881 printf(" ------------------ ------------------ ------------------ ------------------ ------------------ ----------");
887 main(int argc
, char *argv
[])
898 while ((opt
= getopt(argc
, argv
, "eahvrp:")) != -1) {
930 /* also allow lskq <pid> */
931 if (pid
|| all_pids
) {
937 } else if (argc
> 1) {
942 /* exactly one of -p or -a is required */
943 if (!pid
&& !all_pids
) {
946 } else if (pid
&& all_pids
) {
954 return process_all_pids();
956 return process_pid(pid
);