bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: When does a background process complete?


From: Chris F.A. Johnson
Subject: Re: When does a background process complete?
Date: Fri, 21 Sep 2001 18:21:50 GMT

On Fri, 21 Sep 2001, V. Mark Lehky wrote:

> I have written a recursive function (one that calls itself).  In an attempt
> to speed it up, I have made the call to itself in the background, using the
> "&" symbol.
> Here is my problem: I then have a script which calls this function the
> first time.  Subsequent commands in this script need to have everything
> this function does completed.  How can I detect, from my script, when all
> the processes from this function have completed?
> I can post the actual code, if it will help.  Here is almost pseudo-code to
> hopefully descripbe what I am looking for:
>
> function my_function
> {
>    if stop condition false
>       my_function &
>    else
>       return
> }
> # begin script
> my_function
> # now I need to find out if all the background tasks have completed

I haven't tested it, and it may not work will all versions of ps, but how
about something like:

while ps -o pid,ppid | egrep -v 'ps|grep' | grep -qs " $$";do :;done

> continue with script ...
>
> TIA, Mark L.
>

-- 
        Chris F.A. Johnson          bq933@torfree.net
        =================================================================
        c.f.a.johnson@home.com      http://cfaj.freeshell.org
        cfaj@freeshell.org          http://members.home.net/c.f.a.johnson



reply via email to

[Prev in Thread] Current Thread [Next in Thread]