in reply to Timeouts/timers on Win32 system
Could it be that you are looking for Win32::Process? With that you can launch your command and specify $ProcessObj->Wait($timeout) which
-
Wait for the process to die. $timeout should be specified in milliseconds. To wait forever, specify the constant INFINITE.
- Kill the associated process, have it terminate with exit code $ExitCode.
#! /usr/bin/perl use strict; use warnings; use Win32::Process; ###################################################################### +################## #MiscVariables my ($VERSION, $ProcessObj); ###################################################################### +################## $VERSION = "1.0.0"; Win32::Process::Create($ProcessObj, "$ENV{'SystemRoot'}/notepad.exe", "notepad test.txt", 0, # Don't inherit. NORMAL_PRIORITY_CLASS, ".") or die "Cannot Launch Anything\n"; if ($ProcessObj->Wait (10*1000)){ # execution of the process is successfully. $ProcessObj->Kill(0); print "Successful\n"; } else { # process has hung up for some reason print "The Process Hung - Killing it\n"; $ProcessObj->Kill(255); }
Update2: I seem to have gone down the wrong track.. :(
-----Of all the things I've lost in my life, its my mind I miss the most.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Timeouts/timers on Win32 system
by Dovkont (Novice) on Dec 08, 2003 at 15:10 UTC |
In Section
Seekers of Perl Wisdom