Re: Trick at the end of "man 5 proc" doesn't work

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Many strings (i.e., the environment and command line)

I guess this should be "e.g.", not "i.e."?

are in the internal format, with subfields terminated by null bytes ('\0'), so you may find that things are more readable if you use od -c or tr "\000" "\n" to read them. Alternatively, echo `cat <file>` works well.

Another part of this manpage suggests doing:

  strings /proc/PID/environ

which also isn't great: it won't print strings that are very short, and it will truncate strings containing non-ASCII characters.

* Alexander E. Patrakov:
Unfortunately, echo `cat <file>` does not actually work:
[...]

* Florian Weimer <fw@xxxxxxxxxxxxx>, 2018-10-20, 11:49:
Huh.  I'm surprised that it ever worked.  This appears to do the job:

 xargs -0 -n 1 < /proc/$$/environ

It runs echo under the covers, but I think the echo command line syntax is such that at most, you will get no output for an "-n" environment entry.

Yes, this should work for /proc/PID/environ, but /proc/PID/cmdline can naturally contain "-n", and you wouldn't want it hidden.

--
Jakub Wilk



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux