[lug] checking bg processes' exit status
Lori Reed
lorireed at lightning-rose.com
Wed Mar 12 11:59:10 MDT 2008
Nick Golder wrote:
> On 2008-03-04 11:29 -0700, Jeffrey Haemer wrote:
>> Nick,
>>
>> The biggest problem is saving $? for each command, especially when you're
>> throwing some or all of them into the background, so they run in parallel.
>>
>> An easy solution, if practical, is to wrap each process in a shell script
>> that saves its exit status.
>> Thus
>>
>
> Thanks for the example! I was trying to do something very similar sans
> the extra script. I was trying to use a function that gets background'd
> and uses variable to return an exit code. It's ends up not being all
> that elegant since bash doesn't have a garbage collector - all I end up
> doing is polluting the variable space. I could just go through and
> unset all of the variables -or- I could just use your example. When I
> have time I am going to try get this going. One of the targets is a
> read-only filesystem that have nothing that is easily writeable (not my
> design)...
Are you interested in a solution in C? I have sample code that starts
multiple child processes and collects the exit status of each child
process as it exits. This could be easily expanded to do something
interesting with the exit status.
If you're not a C hacker the answer is probably no, or I could be hired
to do what ever is needed. :)
Lori
More information about the LUG
mailing list