Using Win32::Process::Create with multiple child processes.

S

smudgef1

Hello,

I'm using Win32::process::Create to run another program, and then I do
$proc->Wait(INFINITE) to wait for this program to exit. The problem is
the created process immediatly forks another process, and terminates,
and my perl program continues. Is it possible to wait for all the
children to finish executing before continuing?

In case my description wasn't clear, here is a chronology of the
problem.

Perl program A, creates process B;
Perl program A waits for process B to terminate;
Process B forks Process C; (probably similiar to an exec in perl)
Process B terminates;
Process A continues (but I want it to wait on Process C too!);

BTW, process B and C are commerical applications that I don't have the
source for, so I can't modify those.
Thanks!
 
S

Sisyphus

Perl program A, creates process B;
Perl program A waits for process B to terminate;
Process B forks Process C; (probably similiar to an exec in perl)
Process B terminates;
Process A continues (but I want it to wait on Process C too!);

BTW, process B and C are commerical applications that I don't have the
source for, so I can't modify those.

I assume that B does something other than simply create C - otherwise you
could simply have A create C.

Maybe code it so that the first thing A does after B terminates is to
sleep() long enough for C to finish.
Is that feasible ?

Alternatively, if there's some way that A can get hold of C's pid, then you
can tell A to Wait() for C to finish (again, using Win32::process).

Basically, if sleep()ing is not feasible, you need some way for A to be able
to find out when C has stopped - and the fact that A created B created C
does not guarantee that there's a simple way of achieving that.

Cheers,
Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top