PTC MKS Toolkit Knowledge Base

Section:IO
Product:MKS Toolkit (All)
Version:
OS:Win95/Win98/WinMe
Keywords:PID, background processes
Category:Utilities/Knowledge Base


$! does not return PID of background process?


Using the following example:

    $ sleep 10000 &
    [1] 0xfff427e1
    -776223
    $ 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.