/proc/*/cmdline corrupted

Christopher Faylor cgf-use-the-mailinglist-please@cygwin.com
Mon Oct 17 14:19:00 GMT 2011

On Mon, Oct 17, 2011 at 10:27:18AM +0200, Corinna Vinschen 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.

You can change the contents of what __argv[n] points to to modify what
/proc/<pid>/cmdline displays though.


    strcpy (__argv[1], "a");

That's pretty risky though.

>Cygwin doesn't generate a copy of the argv array at startup, so the
>processes __argv is the one used to call the main function.  And I'm
>reluctant to do that since it costs just more time for a process to
>start again.

Just creating a copy of argv without copying what it points to should be
pretty inexpensive.  It's too bad that we export __argv and __argc.  I
don't see Linux doing anything like that and it seems like a way for
a Cygwin program to cause mischief.


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

More information about the Cygwin mailing list