Re: Using "wait" for processes running in the background

From: Gabriel Pacor (gabrielpacor_at_hotmail.com)
Date: 10/08/03


Date: 7 Oct 2003 15:46:09 -0700

Chuck Dillon <cdillon@nimblegen.com> wrote in message news:<blv1t6$1um$1@grandcanyon.binc.net>...
> 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 &
> FIRST_PROC_PID=$!
>
> 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
time.
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?

Cheers,

Gab



Relevant Pages

  • Re: Great SWT Program
    ... xterm instance for each copy of vi it launches. ... as the script blocks until each interactive process it launches ... files don't collectively exceed the command line length limit for the ... "interesting" files to some working directory instead of merely ...
    (comp.lang.java.programmer)
  • Re: Great SWT Program
    ... xterm instance for each copy of vi it launches. ... as the script blocks until each interactive process it launches ... If vi supports multiple documents, ... obviously have been cracking open the MS-DOS manual and writing a .bat ...
    (comp.lang.java.programmer)
  • Re: script to login and run command
    ... I found out the url that launches an update doesn't require a login so ... set objExp = CreateObject ... > How can I run a script that will log into a website and launch a specific ...
    (microsoft.public.scripting.vbscript)
  • Re: script to login and run command
    ... I found out the url that launches an update doesn't require a login so ... set objExp = CreateObject ... > How can I run a script that will log into a website and launch a specific ...
    (microsoft.public.inetserver.asp.general)
  • Re: execute run script from desktop or html
    ... > I have a script that launches an application on my Linux machine ... Hundreds of volunteers worldwide volunteering ...
    (comp.unix.shell)