Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

How do I get output and return code, and time-out the process under Win 32?

by Anonymous Monk
on Apr 05, 2001 at 19:53 UTC ( #70141=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

How do I get output and return code, and time-out the process under Win 32?

Originally posted as a Categorized Question.

  • Comment on How do I get output and return code, and time-out the process under Win 32?

Replies are listed 'Best First'.
Re: How do I get output and return code, and time-out the process under Win 32?
by Anonymous Monk on Apr 11, 2001 at 20:59 UTC
    I managed to get it working myself, using something like the following code:
    open ERROR, ">stderr.txt" or die $!; open OUTPUT, ">stdout.txt" or die $!; open SAVEERR, '>&STDERR' or die $!; open SAVEOUT, '>&STDOUT' or die $!; STDERR -> fdopen (\*ERROR, "w") or die $!; STDOUT -> fdopen (\*OUTPUT, "w") or die $!; $create = Win32::Process::Create($processObj, "program.exe", "-args", +1, NORMAL_PRIORITY_CLASS, "."); if ($create != 0) { if ($processObj->Wait(60000)) { $processObj->GetExitCode($result); } else { $processObj->Kill(999); } }
Re: How do I get output and return code, and time-out the process under Win 32?
by ton (Friar) on Apr 06, 2001 at 02:42 UTC
    Backticks will return the output as of Perl 5.6 (at least for the ActiveState distribution). The return code is stored in $?
    $result = `somesyscall`; $retCode = $?;
    Dunno about timing out a process; you might want to look at Win32::Process, which should comes with the ActiveState distribution. You can also find it on CPAN.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2021-04-21 12:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?