shell script and child pid's

DanKarron at UCBVAX.BERKELEY.EDU DanKarron at UCBVAX.BERKELEY.EDU
Sat Jan 26 07:07:30 AEST 1991


How can I catch the pid of a spawned process from sh ?

karron:~:181sh
# echo xxx &
xxx

# run in foreground, pid is not reported.

6649
# echo xxx > /dev/null &
6650
# run in background, pid is reported.

# xxx=`echo xxx > /dev/null &`
6652

# how do you get thd pid string into a shell variable ?

I know that you can run ps and recover the child pid from the parent pid,
but if the shell is telling you the pid, why not pick it up and use it ?
ps won't be able to tell you which child pid is the one you want if you
spawn a number is like-named children.

There must be a simple trick out there !
Cheers!

dan.

+-----------------------------------------------------------------------------+
| karron at nyu.edu (E-mail alias that will always find me)                      |
| Fax: 212 263 7190           *           Dan Karron, Research Associate      |
| . . . . . . . . . . . . . . *           New York University Medical Center  |
| 560 First Avenue           \*\    Pager <1> (212) 397 9330                  |
| New York, New York 10016    \**\        <2> 10896   <3> <your-number-here>  |
| (212) 263 5210               \***\_________________________________________ |
| Main machine: karron.med.nyu.edu (128.122.135.3) IRIS 85GT                  |
+-----------------------------------------------------------------------------+

NOTE PHONE NUMBER CHANGE: The Med Ctr has changed from 340 to 263 exchange.



More information about the Comp.sys.sgi mailing list