Re: Using "wait" for processes running in the background
From: Gabriel Pacor (gabrielpacor_at_hotmail.com)
Date: 7 Oct 2003 15:46:09 -0700
Chuck Dillon <firstname.lastname@example.org> wrote in message news:<email@example.com>...
> Gabriel Pacor wrote:
> > Sorry about that, that was a mispelling, i've got the $ in front of
> > the variables, but still...flying through....a colleague told me that
> > the wait actually waits for a PID to be assigned to the process by the
> > OS, not the termination
> > of the process itself, cos it's run in the background and therefore
> > it's not considered a "child process"...is this true?
> No on all counts.
> Your post showed:
> runMyFirstProcess.ksh &
> Are you trying to wait for runMyFirstProcess.ksh (actually the shell
> that is interpretting it) or something it launches, as the name
> implies. If it's the latter you can't use wait. If the script runs
> something and then exits your process's child has exited. Your wait
> calls will return the status of the script not what it runs. Your
> process's grandchildren get inherited by init (pid = 1) and you can't
> use wait to wait for them. If this is your situation you either need
> to have your runMyWhateverProcess.ksh scripts wait as well to keep the
> chain in tact or you need to report status by some other means.
> -- ced
Ok, cheers, i'll be more specific :).
For testing purposes, i was running test scripts
(namely runMyFirstProcess.ksh for example) that wouldn't launch
anything, in fact, the scripts were just doing a 'sleep 30', cos i
wanted to simulate a process actually doing something which took some
In reality, the processes that i want to run actually run the Adobe
Distiller Server application, which convert Postcript files to PDF
files. Hence, instead of having a script running (namely
runMyFirstProcess.ksh) for which to wait completion for, i would
invoke the Distiller server directly with some files and run it in the
background, i.e., /blabla/blablabla/Distiller blablabla &
Therefore, in answer to your question, no i'm not running a script
that launches something, i'm launching something directly and running
it on the background....
As i said in my previous post, the recommendation of my colleagues is
to do it the "dirty way", and grep the logs that each process
generates until i reach a certain completion message. I don't believe
this is the only solution (i might be wrong - that's why i'm posting
to you guys) and i want a cleaner solution making use of unix process
signalling rather than greping logs...
I hope this helps on what i'm trying to achieve...so, do you think i
can or can't use 'wait' to wait for the completion of my Distiller
processes? If i can, how can i get the return code of the process by
invoking wait later on in the main script?