]> git.donarmstrong.com Git - bin.git/commitdiff
close FDs before execing PDF stuff
authorDon Armstrong <don@donarmstrong.com>
Sat, 8 Feb 2014 00:56:33 +0000 (16:56 -0800)
committerDon Armstrong <don@donarmstrong.com>
Sat, 8 Feb 2014 00:56:33 +0000 (16:56 -0800)
bibtex_to_paper

index 121a85544354bf60f8f2c2336371f1d8f1802713..23e0085b9478d527f8da39beec3ceffd08b6404d 100755 (executable)
@@ -18,6 +18,7 @@ use File::Spec qw(rel2abs);
 use Text::BibTeX;
 use User;
 use Data::Printer;
+use POSIX;
 
 use DBI;
 
@@ -223,6 +224,11 @@ sub fork_exec {
         die "Unable to fork for some reason: $!";
     }
     if ($child == 0) {
+        foreach (0 .. (POSIX::sysconf (&POSIX::_SC_OPEN_MAX) || 1024))
+           { POSIX::close $_ }
+        open (STDIN, "</dev/null");
+        open (STDOUT, ">/dev/null");
+        open (STDERR, ">&STDOUT");
         exec(@cmd);
     } else {
         return $child;