From: Simon Ruderich Date: Fri, 29 Jan 2016 10:47:31 +0000 (+0100) Subject: run_in_background: redirect to /dev/null instead of using close X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=9cf281cf4a46d31c90fa9df41b8a857a4cf503c0;p=fcscs%2Ffcscs.git run_in_background: redirect to /dev/null instead of using close This the called program can still successfully read/write to stdin, stdout, stderr and the output is discarded. --- diff --git a/Build.PL b/Build.PL index 57f0ad4..6fbf85a 100644 --- a/Build.PL +++ b/Build.PL @@ -31,6 +31,7 @@ my $build = Module::Build->new( # Bundled with perl. 'Encode' => 0, 'Fcntl' => 0, + 'File::Spec' => 0, 'File::Temp' => 0, 'I18N::Langinfo' => 0, 'Pod::Usage' => 0, diff --git a/bin/fcscs b/bin/fcscs index c44b8ea..35e50e3 100755 --- a/bin/fcscs +++ b/bin/fcscs @@ -502,9 +502,11 @@ sub run_in_background { # Necessary for GNU screen or it'll keep the window open until an # external command has run. - close STDIN or die $!; - close STDOUT or die $!; - close STDERR or die $!; + require File::Spec; + my $devnull = File::Spec->devnull(); + open STDIN, '<', $devnull or die $!; + open STDOUT, '>', $devnull or die $!; + open STDERR, '>', $devnull or die $!; # Double-fork to prevent zombies. my $pid = fork;