This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: /proc/*/cmdline corrupted

jan.kolar wrote:
> For example sendmail likes to do that  (on Linux):
>        root      3051  sendmail: accepting connections
>        smmsp 3061  sendmail: Queue runner@00:01:00 for
> /var/spool/clientmqueue
>        root     14631 sendmail: server [] cmd read
>        root     15254 sendmail: ./p9CDUban025571 user
> open
> entries of sendmail are not nullterminated (!).
> Others have set (on Linux) a number of NULL pointers:
> 0000000   i   n   i   t       [   3   ]  \0  \0  \0  \0  \0  \0  \0  \0 
> \0  \0
> 0000000   l   p   d       W   a   i   t   i   n   g  \0  \0  \0

This was on 
Linux host.a.b.c. 2.6.18-194.26.1.el5-ipx #1 SMP Wed Dec 8 20:08:05 CET 2010
x86_64 x86_64 x86_64 GNU/Linux

Corinna Vinschen-2  wrote
> On Linux, /proc/$PID/cmdline always contains the full command line as
> it has been when the process got started, irrespectively of changes
> after process startup.  It looks like the loader creates a copy of the
> argv array before calling main. 

Yes, I agree. A simple C program behaves like that. I did not know how
sendmail, lpd, init and other achieve the change. 
Also perl allows to set $0 with appropriate effect (but not $1).
So,   Q: how they do that ?    A:" It depends " :-)
where (probably) cygwin is SPT_CHANGEARGV and Linux is SPT_REUSEARGV.

(And blind xterm modifies its command line in the case SPT_CHANGEARGV. 
 Do the same other programs using XmParseCommand(), or do they first 
 make a working copy of argv pointer array?)

This works on Linux to change /proc/<cmd>/cmdline:
main (int argc, char **argv)  
{      int i;
        for (i=1; i<argc; i++)            argv[i][0]= 'A'+i ; // ! bad for
"", much bad if last arg is ""
        sleep(30);  }
 ./a.out 1 2 3 4 5 &
ps -fC a.out
A/a.out B C D E F

Thanks for the timeout on proc-IPC !

View this message in context:*-cmdline-corrupted-tp32639066p32666054.html
Sent from the Cygwin list mailing list archive at

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]