Explorar el Código

Fix for https://github.com/OpenGamePanel/OGP-Agent-Linux/issues/62 (#65)

OwN-3m-All hace 6 meses
padre
commit
fa8241548d
Se han modificado 1 ficheros con 12 adiciones y 1 borrados
  1. 12 1
      FastDownload/ForkedDaemon.pm

+ 12 - 1
FastDownload/ForkedDaemon.pm

@@ -112,6 +112,14 @@ else
 }
 
 $SIG{CHLD} = 'IGNORE';
+
+my $origPid = fork();
+
+open(my $old_stderr, '>&', \*STDERR) or die "Can't save STDERR: $!";
+
+my $null_device = (-e '/dev/null') ? '/dev/null' : 'NUL';
+open(STDERR, '>', $null_device) or die "Can't redirect STDERR to $null_device: $!";
+
 while (my $c = $fd->accept) {
 	my $pid = fork();
 	if (not defined $pid)
@@ -141,6 +149,9 @@ while (my $c = $fd->accept) {
 	}
 }
 
+open(STDERR, '>&', $old_stderr) or die "Can't restore STDERR: $!";
+close($old_stderr);
+
 sub process_client_request
 {
 	my($listing, $r, $c) = @_;
@@ -330,4 +341,4 @@ sub in_subnet($$)
 		}
 	}
 	return 0;
-}
+}