in reply to Using IO::CaptureOutput in a child process to caputre STDOUT and STDERR
Update: added a kill.!/usr/bin/perl use strict; use warnings; use IO::CaptureOutput qw(capture capture_exec); use Proc::Killall; use POSIX qw(:signal_h :errno_h :sys_wait_h); &runCommand(); my $pid; unless ( $pid = fork ) { &runCommand(); exit; } $SIG{'CHLD'} = \&Reaper; unless ( $pid = fork ) { &runCommand(); exit; } sub runCommand { my ($stdout, $stderr, $success, $exit_code) = capture_exec('perl', '-e', 'print "Test"'); print "stdout: $stdout\n"; print "stderr: $stderr\n"; print "Success: $success\n"; print "exit code: $exit_code\n"; } sub Reaper { my $pid; waitpid(-1, &WNOHANG); } killall('HUP', -$$);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using IO::CaptureOutput in a child process to caputre STDOUT and STDERR
by Marshall (Canon) on Apr 10, 2011 at 19:16 UTC | |
by Anonymous Monk on Apr 10, 2011 at 22:30 UTC | |
by Marshall (Canon) on Apr 10, 2011 at 23:12 UTC | |
by Anonymous Monk on Apr 10, 2011 at 23:18 UTC | |
by Marshall (Canon) on Apr 11, 2011 at 06:03 UTC | |
|