For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > August 2005 > Using Win32::Process::Create with multiple child processes.









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Using Win32::Process::Create with multiple child processes.
smudgef1@yahoo.com

2005-08-30, 9:56 pm

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!

Sisyphus

2005-08-31, 3:58 am


<smudgef1@yahoo.com> wrote in message

>
> 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


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com