This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ps with command line arguments


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]