X-Recipient: archive-cygwin@delorie.com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:content-type:mime-version:subject:from
	:in-reply-to:date:content-transfer-encoding:message-id
	:references:to; q=dns; s=default; b=QS42EJ2AjCqY1JgswSVzpEsrkrp/
	7euHxVgwyAeEZn3ts0zy3eiZDhfmJoq6QODDEhWFYNGjd9QZ+y0PZjoYzLegehgY
	ux/xQbSCxU2kNIGgK2GC3bSiwT3Ne4KNVoHYjZVfQRR8hLk7rGzBQQMUYQK2Ehe1
	kXzJWavWzwI0B0o=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:content-type:mime-version:subject:from
	:in-reply-to:date:content-transfer-encoding:message-id
	:references:to; s=default; bh=LPxzono0pPtQpo9Ox88JRRhcboA=; b=S+
	jIivSlBVfgmvflqv6J3XzEswNlN8C3MN7bsFPfGtPXO4z6hN6HTmwsAvHdygUFVX
	lbFjOZfzWsrGX8CGqEBwbpll8ik/B3lnO0sNdQAOhgdk2Hsa8UI+ID1wx/uYSZKd
	Pu1H7o7C1z2SlZ7Q0JPrpJ6B78Bn2hyBTHwRDe82Y=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,SPF_PASS autolearn=ham version=3.3.1
X-Received: by 10.180.74.172 with SMTP id u12mr19224005wiv.0.1367933441266;        Tue, 07 May 2013 06:30:41 -0700 (PDT)
Content-Type: text/plain; charset=iso-8859-1
Mime-Version: 1.0 (Apple Message framework v1283)
Subject: Re: ps with command line arguments
From: AZ 9901 <az9901@gmail.com>
In-Reply-To: <ADAB05FC-DE25-4BEC-9362-081C5046E57A@gmail.com>
Date: Tue, 7 May 2013 15:30:37 +0200
Message-Id: <14983C5E-E9B8-49A8-B554-A9C5C026426F@gmail.com>
References: <ADAB05FC-DE25-4BEC-9362-081C5046E57A@gmail.com>
To: cygwin@cygwin.com
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id r47DUwAY000513

Le 7 mai 2013 à 10:46, AZ 9901 a écrit :

> Hello,
> 
> I run a bash script in a multi-user environment.
> This script uses "ps -ef" in particular to list all its instances.
> 
> On a common UNIX / Linux system, it gives something like this :
> bobby     20326 20318  0 10:21 ?        00:00:00 /bin/bash ./myscript.sh
> marty     20330 20342  0 10:23 ?        00:00:00 /bin/bash ./myscript.sh
> dudul     20339 20363  0 10:25 ?        00:00:00 /bin/bash ./myscript.sh
> Perfect !
> 
> With Cygwin, "ps -ef" does not give command line arguments, so the script can't list its instances.
> I was thinking about using procps or printing /proc/*/cmdline.
> However, some of the users do not have admin rights, so they are not allowed to access /proc/<pid>/cmdline, /proc/<pid>/stat etc... of other users...
> 
> This is why "ps -ef" giving command line arguments would be really perfect !

I also just tested a workaround using the bash builtin command "exec".
I put the following lines at the beginning of my script :

if [[ ! "$EXEC" ]]
then
    export EXEC=1
    exec -a myscript /bin/bash "$0" "$@"
fi

Then, on a common UNIX / Linux system, "ps -ef" gives something like this :
bobby     20326 20318  0 10:21 ?        00:00:00 myscript ./myscript.sh
marty     20330 20342  0 10:23 ?        00:00:00 myscript ./myscript.sh
dudul     20339 20363  0 10:25 ?        00:00:00 myscript ./myscript.sh
Perfect.

But on Cygwin, it still gives this :
bobby     20326 20318  0 10:21 ?        00:00:00 /usr/bin/bash
marty     20330 20342  0 10:23 ?        00:00:00 /usr/bin/bash
dudul     20339 20363  0 10:25 ?        00:00:00 /usr/bin/bash

I would have liked to see "myscript" instead of "/usr/bin/bash"...

Could ps command be corrected / improved to display "myscript" and/or command line arguments ?

Or perhaps there is another solution ?

Thank you very much,

Best regards,

Ben


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


