[ANSWER] Re: /proc/<pid>/cmdline

Peter Couvares (pcouvare@family.hampshire.edu)
Wed, 10 Jul 1996 23:44:20 -0400


a.kruczkowski@ic.ac.uk (Mr A.M. ) writes to linux-kernel:

> A brief observation that on my system, cat of /proc/<pid>/cmdline
> gives the cmdline minus spaces between the arguments. Is this
> correct, is my system in need of an upgrade somewhere, or is it an
> error?

No -- they're actually delimited by null characters, which don't
appear as anything when output to your screen. If you "cat
/proc/<pid>/cmdline | less" you'll see things more clearly.

Just about anything, including a space, can be a valid character
_within_ an argument, so only a null can properly delimit two
arguments -- that's why they're used instead of spaces.

Consider the following command:

grep "foo bar" baz

You couldn't accurately represent that in /proc/<pid>/cmdline if
spaces delimited arguments.

-Peter

PS: I'm not sure this thread belonged in linux-kernel to begin with;
move further discussion to email, please.