This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: ps with command line arguments
- From: AZ 9901 <az9901 at gmail dot com>
- To: cygwin at cygwin dot com
- Date: Mon, 20 May 2013 10:32:07 +0200
- Subject: Re: ps with command line arguments
- References: <ADAB05FC-DE25-4BEC-9362-081C5046E57A at gmail dot com> <14983C5E-E9B8-49A8-B554-A9C5C026426F at gmail dot com>
Le 7 mai 2013 à 15:30, AZ 9901 a écrit :
> 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"...
Hello,
Do you think ps command could be corrected / improved to display "myscript" (script's name according to the example above) and/or command line arguments ?
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