waiting for a process to terminate in csh

uunet!bria!mike uunet!bria!mike
Sun Feb 3 11:42:49 AEST 1991


In an article, plains.NoDak.edu!grisanti (Ames Grisanti) writes:
>I am trying to write a shell script using the csh shell
>under SunOS 4.1.  I need some help with keeping track of a 
>process.  I want to execute a process, wait for it to terminate
>and then execute a program after the process is complete.

Some more information about exactly what you're trying to do would
be helpful.  I assume that you are running program "x" in the background,
and want to check to see if it completes?  The obvious answer would be
to not put the program in the background in the first place -- the shell
will wait until it completes, and will then execute the next program.
However, if you are firing up several background programs at once that
depend upon each other (this isn't the case though, is it?), or the
program puts itself in the background, there are few things you could
do (off the top of my head ...):

	1. If you have the source, modify it so that it spits the
	   pid of the forked child before it exits; you can then sit
	   in a loop, and check the exit status using "kill -0".

	2. If you don't have the source, then grep through a ps, and
	   then do the above.  This is admittedly a kludge.

FYI, the kill -0 will not affect the running process; it's used to simply
check the validity of a process id.
-- 
Michael Stefanik                       | Opinions stated are not even my own.
Systems Engineer, Briareus Corporation | UUCP: ...!uunet!bria!mike
-------------------------------------------------------------------------------
technoignorami (tek'no-ig'no-ram`i) a group of individuals that are constantly
found to be saying things like "Well, it works on my DOS machine ..."



More information about the Comp.unix.misc mailing list