Getting PID of background process in shell script.

Roger D. Gough rdg at virtech.uucp
Sun Mar 25 05:56:13 AEST 1990


In article <3074 at auspex.auspex.com> hitz at auspex.auspex.com (Dave Hitz) writes:
>In a shell script I want to start a process in the background and then
>kill it at some later time.  To do this I want to save it's pid in a
>variable.
>
The builtin shell variable $! contains the process number of the last process
run in the background.  So you want to do something like:

		run a command &
		PID=$!
		# do some stuff
		kill $PID
-- 
Roger D. Gough                                                  +1 703 689 1692
Sequel Technologies                                            uunet!sequel!rdg



More information about the Comp.lang.c mailing list