pollinfo —
list file descriptors causing wait in
poll and select
The pollinfo utility lists all threads
(light-weigt processes, lwps) in the process specified by the
id argument, which are sleeping in the
select(2) or
poll(2) families of syscalls. For each such thread, the list
of the file descriptors passed to the syscall to wait for readiness,
together with the type of the wait (read/write/exception) is printed.
If the -v option is specified, additional
information about file descriptors is printed on the same line, in the
format of the
procstat(1) files subcommand.
Passing the -v option twice also prints
internal debugging information about pollinfo
running.
# ps l 2381
UID PID PPID C PRI NI VSZ RSS MWCHAN STAT TT TIME COMMAND
123 2381 1 29 20 0 20584 5604 select Ss - 0:00.39 /usr/sbin/ntpd -p /v
# pollinfo --id 2381 -v
lwp id 100259 (ntpd) selecting on:
20 i s - rw---n-- 1 0 UDP ::.123 ::.0
21 i s - rw---n-- 1 0 UDP *:123 *:0
22 i s - rw---n-- 1 0 UDP 192.168.130.12:123 *:0
23 i s - rw---n-- 1 0 UDP fe80::2a80:23ff:fea2:37bc.123 ::.0
24 i s - rw---n-- 1 0 UDP ::1.123 ::.0
25 i s - rw---n-- 1 0 UDP fe80::1.123 ::.0
26 i s - rw---n-- 1 0 UDP 127.0.0.1:123 *:0
pollinfo is FreeBSD
-specific and only works on FreeBSD.
pollinfo uses
ptrace(2) to attach to the target process and gather
information about sleeping threads and syscall arguments. It needs
permissions to attach, and it must be the only debugger, due to way the
ptrace(2) facility work.
If the process debugging is disabled for the target,
pollinfo cannot work.
Killing pollinfo while the utility is
attached to the target, also kills the target.