4.94.0 November 11, 2020
(All changes in this version are ported from
lsof-org/lsof-linux repository at GitHub).
Introduced a new test harness. The harness can run
test cases specific to a dialect. It is designed for
running test cases on CI environment like Travis-CI.
However, it is runnable locally with following command
line:
$ ./check.sh DIALECT
after making lsof executable.
[linux] Fixed a bug +|-E options output for pipe.
If two processes use the same fd number for a pipe
connecting them, the option didn't print the
information about it.
[linux] Fixed a bug +|-E options output for PTY.
If two processes use the same fd number for a PTY
connecting them, the option didn't print the
information about it.
[linux] Fixed a bug +|-E options output for PTY.
The code for detecting a slave device was incorrect.
[linux] Fixed a potential bug +|-E options output for
PTY. A structure field for the feature was not
initialized.
[linux] Added a code for decoding O_PATH flag in +fg
option.
[linux] Added a code for decoding O_CLOEXEC flag as CX
in +fg option.
[linux] Added a code for decoding O_TMPFILE flag as
TMPF in +fg option.
[linux] Added Linux display of INET socket endpoint
information with +|-E option. The option handles
INET sockets using IPC.
[linux] Added support for POSIX MQ of Linux
implementation. A POSIX message queue (MQ) is
represented in a fd on Linux. lsof reported it as a
regular file. lsof with this change reports it as a
file with PSXMQ type if mqueue file system is mounted.
[linux] Added Linux display of POSIX message queue
endpoint information with +|-E option. mqueue file system
must be mounted to display the information.
[linux] Added Linux display of INET6 socket endpoint
information with +|-E option. The option handles
INET6 sockets using IPC.
[FreeBSD] update to include <sys/_lock.h> on recent -CURRENT
since it is no longer implicitly included via header pollution.
[linux] Added Linux display of eventfd endpoint information
with +|-E option. The option handles eventfd using IPC.
[FreeBSD] include <stdbool.h> for recent change requiring
refcount(9).
Enhanced -r option. With `c<N>' specifier, lsof can stop itself
when the number of iterations reaches at <N>.
[linux] Fixed accessing an uninitialized local variable.
Detected by valgrind.
[linux] fix a crash when printing the endpoint for unaccepted
unix socket with +E option.
This closes the github issue #74 reported by @jolmg.
[linux] abort execution when failing in memory allocation for
socket private data.
[linux] decode the name of DCCP socket type.
[linux] decode more netlink protocol numbers (RDMA, CRYPTO, and
SMC).
[linux] print the connection state of unix domain socket
Lsof can print the state of TCP socket like:
nc 22247 yamato 3u IPv4 471409 0t0 TCP localhost:38802->localhost:9999 (ESTABLISHED)
This change exnteds this feature to support unix domain sockets.
LISTEN, UNCONNECTED, CONNECTING, CONNECTED, DISCONNECTING,
and UNKNOWN can be taken as a state.
An example of output:
evince 17333 yamato 1u unix 0x0000000054183795 0t0 89141 type=STREAM (CONNECTED)
This feature is enabled by default.
To turn off printing state information, use -T option.
Don't display command usage even when a file (or directory) listed
in command line doesn't exist.
This closes the github issue #90 reported by @rowlap.
[FreeBSD] merge all the FreeBSD specific fixes from the FreeBSD sysutils/lsof port
[linux] allow reproducible builds
In a reproducible build all varied information is removed. This
change does so, by checking if the standard SOURCE_DATE_EPOCH
variable is set. If it is, we are attempting a reproducible build
and will strip varying information.
About the standard, see https://reproducible-builds.org/specs/source-date-epoch/
Provided in github pull request #93 by @T4cC0re.
[freebsd] update for r363214
- no user visible changes
Added the way to include (or exclude) all numbered file descriptors
in -d option. "fd" is a pseudo file descriptor name for the purpose.
See the following output on Linux; lsof doesn't print cwd, rtd, txt,
and mem files.
# ./lsof -p $$ -a -d fd
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
bash 866421 root 0u CHR 136,1 0t0 4 /dev/pts/1
bash 866421 root 1u CHR 136,1 0t0 4 /dev/pts/1
bash 866421 root 2u CHR 136,1 0t0 4 /dev/pts/1
bash 866421 root 255u CHR 136,1 0t0 4 /dev/pts/1
docs: fixed minor grammatical error in instructions in Customize file
The change is provided by @hardikpnsp.
man page: improve phrasing and add examples
The change is provided by Martin D Kealey.
man page: improve explanation of -t implying -w
The change is provided by Martin D Kealey.
test cases, [linux]: fix tests for large inode-numbers (i >= 2^32)
The change is provided by Henry Peteet.
[linux] handle ffff:ffff in ipv6 addr correctly
The listen address and port of an AF_INET6 socket were not display if
the socket listened at an ipv6 address including ffff:ffff.
Here is a command session demonstrating the bug:
# ip -6 addr add abcd:ef10:ffff:ffff:ffff:ffff:ffff:ff62 dev lo
# nc -6 -l abcd:ef10:ffff:ffff:ffff:ffff:ffff:ff62 8888 &
[1] 6762
# ./lsof -p 6762 -a -d fd -P -n
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nc 6762 yamato 0u CHR 136,6 0t0 9 /dev/pts/6
nc 6762 yamato 1u CHR 136,6 0t0 9 /dev/pts/6
nc 6762 yamato 2u CHR 136,6 0t0 9 /dev/pts/6
nc 6762 yamato 3u sock 0,9 0t0 5833594 protocol: TCPv6
The last line should be:
nc 6762 yamato 3u IPv6 5833594 0t0 TCP [abcd:ef10:ffff:ffff:ffff:ffff:ffff:ff62]:8888 (LISTEN)
The original code decoding an ipv6 address uses UINT32_MAX constant
incorrect way.
@zhrf2020 reported this bug in #102.
@zhrf2020 provided the initial version of fix, #109.
man page,[linux]: enumerate abbreviated flags printed with '+f g' option
Make -Fo option work
-Fo option is for printing file offset. For regular files,
the option didn't work.
Here is a command session demonstrating the fix:
# ./lsof -Fo -o0| grep ^o | sort | uniq -c
90586 o0t0
87 o0t101
84 o0t103
...
@JustAnotherArchivist reported this bug in #118.
man page: fix definition of the `o` field on programmatic output
The change is provided by @JustAnotherArchivist who reported
the original issue in #118.
[linux]: show the pid monitored by a pidfd
With this change, lsof prints pidfd in the following form:
[pidfd:%d]
where %d represents the pid monitored by the pidfd.
Example output:
# ./lsof -p 12573 -p 12710 | grep pidfd
dbus-brok 12573 jet 11u a_inode 0,13 0 13312 [pidfd:12575]
dbus-brok 12710 jet 10u a_inode 0,13 0 13312 [pidfd:12711]
fd 11 of pid 12573 monitors pid 12575.
fd 10 of pid 12710 monitors pid 12711.
This change closed #116.
Don't select the file descriptor field by default.
The version 4.88 introduced the change for selecting the file
descriptor field by default. However, the change is not
suitable for users who wants to print only PID field.
@po5857 suggests the use case and the way to improve the man page.
[linux]: enumerate fds monitored by an eventpoll fd
With this change, lsof prints an eventpoll fd in the following form:
[eventpoll:<fd0>,<fd1>,...,<fdn>...]
Here fdX is a file descriptor monitored by the eventpoll fd.
If an eventpoll fd monitors too many file descriptors, lsof
truncates the list of fds. "..." at the end of list implies
the truncation.
Example output:
# sudo ./lsof -p 1 -a -d 10,11,12
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
systemd 1 root 10u a_inode 0,13 0 11624 [eventpoll:11,12]
systemd 1 root 11r REG 0,4 0 17680 /proc/1/mountinfo
systemd 1 root 12r a_inode 0,13 0 11624 inotify
systemd monitors fd 11 and fd 12 via eventpoll fd 10.
[linux]: implement "make check"
The target runs check.bash.