#!/usr/bin/perl use Data::Dumper; use IO::CaptureOutput qw/capture_exec/; # The first test shows the Success = 1 &runCommand(); # Now the same thing in a child process shows Success = 1 unless ( $pid = fork ) { &runCommand(); exit; } # Now child process with IGNORE set, shows Success = 0 $SIG{CHLD} = 'IGNORE'; unless ( $pid = fork ) { &runCommand(); exit; } sub runCommand { ($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"; }