#!/usr/bin/perl use strict; use warnings; use Win32::Process; use Win32; $|++; #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # spawn process #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ my $process="c:\\perl\\bin\\perl.exe"; my $output="nothing"; open OUT, ">", \$output; select OUT; my $ProcObj; Win32::Process::Create ( $ProcObj, $process, "perl printer.pl 1 2 3", 0, NORMAL_PRIORITY_CLASS, "." ) or die "Create process failed: $!"; #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # wait 10 seconds for process to finish #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ unless ( $ProcObj->Wait(10000) ) # waits for 10,000 milliseconds { #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # process has not completed, so return # result for monitoring probe and kill # wntmon process #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ print "-1"; $ProcObj->Kill(2001); } print "Ball cocks\n"; select STDOUT; print "output was: $output\n"; __END__ # printer.pl just prints the @ARG array it gets # output is this C:\PERL\bin>perl test_proc.pl this was called with: 1, 2, 3 output was: Ball cocks