ps refuses to recognize proc mounted with "subset=pid"
When running ps
in a pidns for which /proc was mounted with subset=pid
ps just complains that proc would not be mounted.
#ps
Error: /proc must be mounted
To mount /proc at boot you need an /etc/fstab line like:
proc /proc proc defaults
In the meantime, run "mount proc /proc -t proc"
#grep proc /proc/self/mounts
proc /proc proc ro,nosuid,relatime,hidepid=invisible,subset=pid 0 0
Running ps
with proc mounted with default options causes it to look for a few non-process files:
openat(AT_FDCWD, "/proc/sys/kernel/osrelease", O_RDONLY) = 3
openat(AT_FDCWD, "/proc/self/auxv", O_RDONLY) = 3
openat(AT_FDCWD, "/proc/self/stat", O_RDONLY) = 3
openat(AT_FDCWD, "/proc/uptime", O_RDONLY) = 3
openat(AT_FDCWD, "/proc/sys/kernel/pid_max", O_RDONLY) = 4
openat(AT_FDCWD, "/proc/sys/kernel/osrelease", O_RDONLY) = 4
openat(AT_FDCWD, "/proc/meminfo", O_RDONLY) = 4
Running ps
with proc mounted with subset=pid option causes it to abort when failing to open /proc/uptime
openat(AT_FDCWD, "/proc/self/auxv", O_RDONLY|O_LARGEFILE) = 3
openat(AT_FDCWD, "/proc/sys/kernel/osrelease", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/proc/stat", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/proc/cpuinfo", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/proc/self/stat", O_RDONLY|O_LARGEFILE) = 3
openat(AT_FDCWD, "/proc/uptime", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
# printing Error message and exiting
It seems this is libprocps.so
that wants more information than what a simple ps
call would output.
See https://www.kernel.org/doc/html/latest/filesystems/proc.html#chapter-4-configuring-procfs for proc mount options
subset=pid
was introduced with commit 6814ef2d992af09451bbeda4770daa204461329e (April 2020)