getting the pid from the csh
Rob Warnock
rpw3 at redwood.UUCP
Thu Feb 14 20:53:40 AEST 1985
+---------------
| ss at wanginst.UUCP (Sid Shapiro) writes:
| > So I cheerfully set off to try and figure out how to capture the pid
| > that is returned when you type foo&
| In sh, on the other hand, you need only type: (foo&) 2>foo.pid
| Mark Brader
+---------------
In the Bourne Shell (either Edition 7 or 4.1bsd) the (parent) shell
variable "$!" contains the process number of the last background
process evoked. You don't need to write it into a file. Try:
$ foo &
$ ... # anything but another background invocation
$ echo $!
It works as documented. See "sh(1)".
Rob Warnock
Systems Architecture Consultant
UUCP: {ihnp4,ucbvax!dual}!fortune!redwood!rpw3
DDD: (415)572-2607
USPS: 510 Trinidad Lane, Foster City, CA 94404
More information about the Comp.unix
mailing list