Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Timeouts/timers on Win32 system

by AcidHawk (Vicar)
on Dec 08, 2003 at 15:03 UTC ( [id://313095]=note: print w/replies, xml ) Need Help??


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.
then to kill the process you could do something like $ProcessObj->Kill( $exitcode ) which
    Kill the associated process, have it terminate with exit code $ExitCode.
Update:
#! /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
    Unfortunately, this is not the way - since I need not only to shut the program down, but to undertake a number of maintainance procedures, that are located in a sub of the server script. Also, the Win32::Process->Wait($timeout) is waiting for the process to shutdown, and if that does not occur for $timeout, then the process is being shut down. And that is absolutely not what is needed :(

    Also, alarm does not work on Windows, as far as I recall.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-19 15:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found