Re: Waiting for _any_ background process to terminate.
From:
Greg Wooledge
Subject:
Re: Waiting for _any_ background process to terminate.
Date:
Mon, 11 Feb 2013 14:34:53 -0500
User-agent:
Mutt/1.4.2.3i
On Mon, Feb 11, 2013 at 06:59:35PM +0000, Alan Mackenzie wrote:
> From a bash script, I'd like to be able to start several subtasks and
> react to any one of them completing. I don't think I can do this with
> the current bash. The `wait' function either waits on a specified subtask
> to finish, or for _all_ subtasks to finish.
This is more of a help-bash matter than a bug-bash one.
The general approach is these cases is to set up a trap for SIGCHLD.
> The sort of thing I want to do with this is to perform lots of gzippings
> in separate tasks, so as to spread them amongst the cores of my 4-core
> processor, always keeping 4 subtasks on the go at any time.
Oh, THAT particular problem. See
http://mywiki.wooledge.org/ProcessManagement#Advanced_questions