]> ruderich.org/simon Gitweb - fcscs/fcscs.git/commitdiff
run_in_background: redirect to /dev/null instead of using close
authorSimon Ruderich <simon@ruderich.org>
Fri, 29 Jan 2016 10:47:31 +0000 (11:47 +0100)
committerSimon Ruderich <simon@ruderich.org>
Fri, 29 Jan 2016 10:47:31 +0000 (11:47 +0100)
This the called program can still successfully read/write to stdin,
stdout, stderr and the output is discarded.

Build.PL
bin/fcscs

index 57f0ad4d723606255dbcccadb01445fdecf6e7d0..6fbf85a4ca4670a4d5d572f31ac256b21127517e 100644 (file)
--- a/Build.PL
+++ b/Build.PL
@@ -31,6 +31,7 @@ my $build = Module::Build->new(
                             # Bundled with perl.
                             'Encode' => 0,
                             'Fcntl' => 0,
                             # Bundled with perl.
                             'Encode' => 0,
                             'Fcntl' => 0,
+                            'File::Spec' => 0,
                             'File::Temp' => 0,
                             'I18N::Langinfo' => 0,
                             'Pod::Usage' => 0,
                             'File::Temp' => 0,
                             'I18N::Langinfo' => 0,
                             'Pod::Usage' => 0,
index c44b8eaeb623c53846ee2b8f8c22931acc56e17f..35e50e3a4fe7891e9018df4edb30ab20ca7527cb 100755 (executable)
--- 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.
 
         # 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;
 
         # Double-fork to prevent zombies.
         my $pid = fork;