ps weirdness...

Corinna Vinschen corinna-cygwin@cygwin.com
Wed Oct 23 12:56:00 GMT 2013


On Oct 21 18:09, cygwin wrote:
> When I type 'ps', I get as expected the following processes:
> 
>       PID    PPID    PGID     WINPID   TTY     UID    STIME COMMAND
>     18036    3188   18036      17792  pty0    1001 16:54:33 /usr/bin/ps
>      3188    1688    3188       3212  pty0    1001 06:59:16 /usr/bin/bash
>      1688       1    1688       1688  ?       1001 06:59:15 /usr/bin/mintty
>      2392       1    2392       2392  ?       1001 11:00:03 /usr/bin/ssh-agent
> 
> When I type 'ps | grep bash', about 2/3 of the time, I get:
>  	 3188    1688    3188       3212  pty0    1001 06:59:16 /usr/bin/bash
> 
> HOWEVER, about 1/3 of the time, I get:
>   16832    3188   17792      16832  pty0    1001 16:56:44 /usr/bin/bash
>   3188    1688    3188       3212  pty0    1001 06:59:16 /usr/bin/bash

When you pipe ps to grep, the shell forks and execs two processes, ps
and grep.  What you see is one of the forked bash processes.  They are
shortlived, but depending on the order of execution they may still
linger in the process list when ps creates the process list.

> And there is no bash process launched in the interim. Moreover, this
> second PID jumps around (both up and down) wildly rather than being
> constant or even relatively sequential.

PIDs under Windows are not sequential.

> In such cases, ps -W, similarly generates 2 bash processes:
> 
>      3188    1688    3188       3212  pty0    1001 06:59:16 /usr/bin/bash
>     16460       0       0      16460  pty0    1001 17:44:29 C:\cygwin\bin\bash.exe
> 
> Even more interesting, when I type 'ps | grep ssh-agent', about 2/3 of the time, I get:
>   2392       1    2392       2392  ?       1001 11:00:03 /usr/bin/ssh-agent
> 
> HOWEVER, about 1/3 of the time, I get:
>   2392       1    2392       2392  ?       1001 11:00:03 /usr/bin/ssh-agent
>   19176       0       0      19176  pty0    1001   Dec 31 /usr/bin/ssh-agent

Hmm, I can't reproduce this one.  I tried a hundreds of times, but
there was not a single instance of bash shown as a Windows process.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20131023/084e0bf6/attachment.sig>


More information about the Cygwin mailing list