This is the mail archive of the
mailing list for the Cygwin project.
Re: /proc/*/cmdline corrupted
On 10/16/11 14:31, jan.kolar wrote:
Why wouldn't exec(1) be responsible for setting up /proc and therefore
fill in cmdline with effectively $0 *before* the program itself ever got
around to calling XrmParseCommand? (I'm not well versed in the
underlying mechanics here and I have not reviewed the code but I would
have thought that something like exec would have examined argv/argc
before the program was ever able to modify it).
jc807j 2668 1 0 08:59 tty0 00:00:00 xterm -e ssh server
80x72+285+0 -e ssh server
jc807j 3004 1 0 08:59 tty0 00:00:00 xterm -e ssh server
80x72-8+0 -e ssh server
jc807j 2928 5852 0 09:12 ? 00:00:00 xterm 20000 +tb
The actual command lines for the 3 xterm processes are:
C:\cygwin\bin\xterm.exe -sl 20000 +tb -geometry 80x72+285+0 -e ssh server
C:\cygwin\bin\xterm.exe -sl 20000 +tb -geometry 80x72-8+0 -e ssh server
C:\cygwin\bin\xterm.exe -sl 20000 +tb
xterm calls XrmParseCommand() that
"parses an (argc, argv) pair according to the specified option table ... and
modifies the (argc, argv) pair to remove all recognized options."
"-sl 20000 +tb -geometry 80x72+285+0"
is properly removed
and "-e ssh server" is moved to __argv[1 .. 3].
Then __argv (respectively __argv for the shorter command) is assigned
which results in the second "\0" in the od-output below.
Either XrmParseCommand() does not update argc
or the change does not propagate (how would that be possible?) to __argc.
Therefore the command lines appear corrupted this particular way.
/proc/*/cmdline uses a copy of __argc named __argc_safe
which is hardly to be updated anyway.
" for (int i = 0; i< __argc_safe; i++) "
Funny enough, /proc/self/cmdline is likely to contain shortened version of
" for (char **a = __argv; *a; a++)"
[ pinfo.cc from cygwin 1.7.9-1 ]
Andrew DeFaria <http://defaria.com>
Chastity is curable if detected early.
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple