Bourne sh/subshell question

Steve Mawer scm at dlcq15.datlog.co.uk
Fri Nov 17 21:58:28 AEST 1989


I have a small problem with the following script:

---------------------SCRIPT STARTS----------
(
    echo subshell - $$
    sleep 10
) &
echo shell - $!
----------------------SCRIPT ENDS-----------

When run, it produces the following output:

$ sh script
subshell - 25654
shell - 25655
$

My question is twofold, firstly why aren't the two PIDs identical,
and secondly, as they're not, why is the PID of the last background
process 1 greater than the current process PID of the subshell?

E-mail replies for preference, I'll summarize if there's sufficient
interest.

--
Steve C. Mawer        <scm at datlog.co.uk> or < {backbone}!ukc!datlog!scm >
                       Voice:  +44 1 863 0383 (x2153)



More information about the Comp.unix.questions mailing list