Path: utzoo!attcan!uunet!decwrl!sgi!shinobu!odin!lavalite.asd.sgi.com!rlb From: rlb@lavalite.asd.sgi.com (Robert Brown) Newsgroups: comp.sys.sgi Subject: Re: shell script and child pid's Message-ID: <1991Jan26.161528.26723@odin.corp.sgi.com> Date: 26 Jan 91 16:15:28 GMT References: <9101252007.AA06669@karron.med.nyu.edu> Sender: news@odin.corp.sgi.com (Net News) Reply-To: rlb@lavalite.asd.sgi.com (Robert Brown) Organization: Silicon Graphics, Inc., Mountain View, CA. Lines: 26 In article <9101252007.AA06669@karron.med.nyu.edu>, Dan Karron@UCBVAX.BERKELEY.EDU writes: |> |> How can I catch the pid of a spawned process from sh ? |> |> 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. The built-in shell variable $! contains it: $ sleep 60 & 1990 $ echo $! 1990 $ Bob Brown ------------------------------------------------------------------ Silicon Graphics, Inc. Advanced Systems Division 415 335 7299