PTC MKS Toolkit Knowledge Base

Product:MKS Toolkit (All)
Keywords:PID, background processes
Category:Utilities/Knowledge Base

$! does not return PID of background process?

Using the following example:

    $ sleep 10000 &
    [1] 0xfff427e1
    $ ps | grep sleep
    0xFFF4E619 32C sleep 10000
    0xFFF4AF79 32C sleep 10000

$! is NOT returning the PID for the background process.

This is not a MKS bug, Win95 violates POSIX, it is returning a negative pid, which is illegal in the POSIX.1 specification.

On the other hand, if this is occurring in a subshell, it is attributable to the fact that Windows does not have an overlaying exec() call.