public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: "jan.kolar" <kolar@math.cas.cz>
To: cygwin@cygwin.com
Subject: Re: /proc/*/cmdline corrupted
Date: Sun, 16 Oct 2011 21:31:00 -0000	[thread overview]
Message-ID: <32663265.post@talk.nabble.com> (raw)
In-Reply-To: <CAG_2cT=rmeJpmZbYDo7RAwjNcTTDSTH1SMhuzzL9qi09ZJwGyA@mail.gmail.com>


> 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."

Therefore 
         "-sl 20000 +tb -geometry 80x72+285+0"
is properly removed 
and "-e ssh server" is moved to __argv[1 .. 3].
Then __argv[4] (respectively __argv[1] for the shorter command) is assigned
null pointer
which results in the second "\0" in the od-output below.


HOWEVER:

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
cmdline:
"     for (char **a = __argv; *a; a++) "
[ pinfo.cc from cygwin 1.7.9-1 ]



> I have verified that the "/proc/*/cmdline" is the source of the
> corrupted information.  "cmdline" from PID 2928 is:
>
> jc807j@~>od -c /proc/2928/cmdline
> 0000000   x   t   e   r   m  \0  \0   2   0   0   0   0  \0   +   t   b
> 0000020  \0
> 0000021






----
 What does xterm on different platforms ?
 While concept of modifying own cmdline (In fact, __argv[0]) is used very
 often to signal the process state down to the user,
 I was never thinking of modifying argc:
     main (int argc, char **argv)
 :-)


JK
-- 
View this message in context: http://old.nabble.com/-proc-*-cmdline-corrupted-tp32639066p32663265.html
Sent from the Cygwin list mailing list archive at Nabble.com.


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

  parent reply	other threads:[~2011-10-16 21:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-12 15:08 Jon Clugston
2011-10-13 12:56 ` jan.kolar
2011-10-13 13:02   ` Christopher Faylor
2011-10-13 18:02 ` Jon Clugston
2011-10-13 18:14   ` Andrew DeFaria
2011-10-17 16:47   ` jan.kolar
2011-10-17 23:29     ` Jon Clugston
2011-10-16 21:31 ` jan.kolar [this message]
2011-10-16 23:59   ` Andrew DeFaria
2011-10-17  7:42     ` jan.kolar
2011-10-17  8:30       ` Corinna Vinschen
2011-10-17  8:28     ` Corinna Vinschen
2011-10-17 14:19       ` Christopher Faylor
2011-10-17 15:54         ` jan.kolar
2011-10-17  0:17   ` Jon Clugston
2011-10-17  8:34     ` jan.kolar
2011-10-17 10:41       ` jan.kolar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=32663265.post@talk.nabble.com \
    --to=kolar@math.cas.cz \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).