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.