X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RP_MATCHES_RCVD,TW_RG,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Message-ID: <32666054.post@talk.nabble.com> Date: Mon, 17 Oct 2011 03:41:29 -0700 (PDT) From: "jan.kolar" To: cygwin AT cygwin DOT com Subject: Re: /proc/*/cmdline corrupted In-Reply-To: <32665348.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit References: <32663265 DOT post AT talk DOT nabble DOT com> <32665348 DOT post AT talk DOT nabble DOT com> X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com jan.kolar wrote: > > For example sendmail likes to do that (on Linux): > root 3051 sendmail: accepting connections > smmsp 3061 sendmail: Queue runner AT 00:01:00 for > /var/spool/clientmqueue > root 14631 sendmail: server [1.46.244.248] cmd read > root 15254 sendmail: ./p9CDUban025571 mail3.cae3.com.: 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 exactly 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 " :-) See http://cvs.rutgers.edu/cgi-bin/viewvc.cgi/tags/start/postman1.11/PsTitle.cc?revision=1806&view=markup 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//cmdline: main (int argc, char **argv) { int i; argv[0][0]='A'; for (i=1; i