Sample Header Ad - 728x90

Why does wc and stat produce different results for /proc/[pid]/cmdline?

6 votes
2 answers
977 views
I am trying to understand why wc and stat report different things for /proc/[pid]/cmdline. wc says my shell's cmdline file is 6 bytes in size:
$ wc --bytes /proc/$$/cmdline
6 /proc/10425/cmdline
stat says the file is 0 bytes in size:
$ stat --format='%s' /proc/$$/cmdline
0
file agrees with stat:
$ file /proc/$$/cmdline
/proc/10425/cmdline: empty
cat gives this output:
$ cat -vE /proc/$$/cmdline
-bash^@
All of this is on Linux rather than on any other *nix OS. Do the stat and wc programs have a different algorithm for computing the number of bytes in a file?
Asked by Shane Bishop (509 rep)
Feb 1, 2023, 07:34 PM
Last activity: Feb 2, 2023, 09:50 AM