Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!eecae!tank!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.unix.wizards Subject: Re: shell script puzzler Keywords: /bin/sh Message-ID: <16489@mimsy.UUCP> Date: 22 Mar 89 10:47:18 GMT References: <995@etnibsd.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 15 In article <995@etnibsd.UUCP> vsh@etnibsd.UUCP (Steve Harris) writes: >Here is one for the shell programming gurus: given the following >shell script, how can I get the subshell to echo its true pid?? >(I am running SunOS 3.4, if it matters). >#! /bin/sh >echo $$ # echos pid of parent shell >( echo $$ ) # echos same pid At least in 4BSD, you cannot. `sh' sets up `$$' near the top of main() and never changes it (except when running a script, in lieu of starting a new /bin/sh to run it). -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris