Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Re: Re: Re: system() with timeout

by clintp (Curate)
on Mar 18, 2004 at 19:36 UTC ( #337780=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Re: system() with timeout
in thread system() with timeout

Under Win32, create a separate thread and start your external process under that thread. Back in the parent thread, start counting until you want the timout to expire (or Wait() for it) then kill the thread. It looks something like this:

Win32::Process::Create($proc, "c:\foo.exe", "foo.exe arg1 arg2 arg3", 0, $priority, ".") || die "can't create process, ". Win32::FormatMessage( Win32 +::GetLastError()); my $ret= $proc->Wait($timeoutsecs * 1000); if (! $ret ) { # Still running, kill it. $proc->Kill(0); }


Comment on Re: Re: Re: Re: system() with timeout
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://337780]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2015-07-07 03:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (86 votes), past polls