Andrew Pantyukhin wrote:
On 11/8/06, nicky <[EMAIL PROTECTED]> wrote:
I have to start 2 processes in the background (running in parallel),
capture their return codes and after all 4 have completed successfully i
want to continue with the main script.

What do you need their return codes for? If you
only want to display them, something like this
might help:

(/bin/proc1;echo "Proc 1 exited with status $?) &
(/bin/proc2;echo "Proc 2 exited with status $?) &
wait

In general, retrieving exit statuses of multiple
general is not trivial. I.e. you need some kind of
IPC for that, at least store statuses in some tmp
files and read it back from the main process.


The whole idea is this. I have to extract two different databases to csv files. One takes about an 1 hour, the other 1.5 hours. The problem is my time window, which is 2 hours. So extracting one after the other is not an option. After both extractions are complete, it should load the csv files into a target database.

I figured it would be best to launch the two extraction processes in a child process and just let the main process wait till they are complete. It should then check if the extraction processes completed successfully and proceed to load the data into the target database.

My concept script seems to work, but i'm dubious about something. If childprocessA takes longer then childprocessB. The main script is still waiting for childprocessA, while childprocessB has already completed it's run. So, if i am correct, the PID of childprocessB does not exist anymore. So calling 'wait [childprocessB pid]', would it always return 0 or will it still return the actual return code?

This just makes me doubt if my concept script is the proper solution for my problem.


_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to