in reply to Re^2: Win32::Process output
in thread Win32::Process output
Try this (from a couple of posts down from the link I provided at:633867):
#! perl -slw use strict; sub timedCommand { use threads; use threads::shared; my( $cmd, $timeout ) = @_; my @results :shared; my $pid :shared; async { $pid = open my $fh, "$cmd |" or die "$!, $^E"; @results = <$fh>; }->detach; kill 0, $pid while sleep 1 and $timeout--; kill 3, $pid and return if $timeout; return @results; } ... ## Run foo.exe, kill it after 20 seconds. my @results = timedCommand( 'foo.exe -opt', 20 ); ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Win32::Process output
by Anonymous Monk on Nov 03, 2010 at 22:36 UTC | |
by BrowserUk (Patriarch) on Nov 04, 2010 at 00:33 UTC | |
by Anonymous Monk on Nov 04, 2010 at 01:01 UTC | |
by BrowserUk (Patriarch) on Nov 04, 2010 at 03:24 UTC | |
by tawnos (Novice) on Nov 04, 2010 at 16:14 UTC | |
|