delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/10/17/10:19:27

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,RCVD_IN_DNSWL_NONE,TW_CP,TW_RG,UNPARSEABLE_RELAY
X-Spam-Check-By: sourceware.org
X-Yahoo-SMTP: jenXL62swBAWhMTL3wnej93oaS0ClBQOAKs8jbEbx_o-
Date: Mon, 17 Oct 2011 10:18:48 -0400
From: Christopher Faylor <cgf-use-the-mailinglist-please AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: /proc/*/cmdline corrupted
Message-ID: <20111017141848.GD2054@ednor.casa.cgf.cx>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <CAG_2cT=rmeJpmZbYDo7RAwjNcTTDSTH1SMhuzzL9qi09ZJwGyA AT mail DOT gmail DOT com> <32663265 DOT post AT talk DOT nabble DOT com> <j7fr4c$mmf$1 AT dough DOT gmane DOT org> <20111017082718 DOT GC30527 AT calimero DOT vinschen DOT de>
MIME-Version: 1.0
In-Reply-To: <20111017082718.GC30527@calimero.vinschen.de>
User-Agent: Mutt/1.5.20 (2009-06-14)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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.

i.e.,

    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.

cgf

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019