delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/10/17/03:42:09

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,T_TO_NO_BRKTS_FREEMAIL
X-Spam-Check-By: sourceware.org
Message-ID: <32665088.post@talk.nabble.com>
Date: Mon, 17 Oct 2011 00:41:45 -0700 (PDT)
From: "jan.kolar" <kolar AT math DOT cas DOT cz>
To: cygwin AT cygwin DOT com
Subject: Re: /proc/*/cmdline corrupted
In-Reply-To: <j7fr4c$mmf$1@dough.gmane.org>
MIME-Version: 1.0
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>
X-IsSubscribed: yes
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



defaria wrote:
> 
> Why wouldn't exec(1) be responsible for setting up /proc and therefore 
> fill in cmdline with effectively $0 *before* the program itself ever got 
> around to calling XrmParseCommand? (I'm not well versed in the 
> underlying mechanics here and I have not reviewed the code but I would 
> have thought that something like exec would have examined argv/argc 
> before the program was ever able to modify it).
> 

The command line is in the memory space of the process.
Exec does set it at the beginning but the program can change it.

On ancient unix, program 'ps' was looking in the memory of each process
(and therefore it was running setuid root).
On modern unix, kernel provides /proc filesystem whose implementation 
is looking into (I suppose) the memory of each process.
On cygwin, the library cygwin1.dll (it is 2011 this year) provides
filesystem, whose implementation
asks each other cygwin process about content of command line.
In the process, a separate thread created by cygwin1.dll assemblies the
answer.

* Might be, it would be reasonable to set a suitable timeoutsfor IPC
connected to /proc
   so that programs likes procps (I do not know about ps) will not get stack
   instead of reporting problem, when there is non-responding process,
either corrupted or held
   for example in debuger.
   I suppose that 'kernel' proc IPC (infinite timeouts) and 'user' proc IPC
(timeouts of several seconds?)
   should be distinguished. 

(On windows, I suppose CreateProcess (besides putting the command line in
the process
memory space) writes the command line to a kernel table 
where from taskmanager.exe queries its content forever unchanged.)

-- 
View this message in context: http://old.nabble.com/-proc-*-cmdline-corrupted-tp32639066p32665088.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

- Raw text -


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