Browse Source

Merge pull request #30 from own3mall/master

FastDL Fix
OwN-3m-All 6 months ago
parent
commit
7ed41b4dbe
1 changed files with 12 additions and 1 deletions
  1. 12 1
      OGP/FastDownload/ForkedDaemon.pm

+ 12 - 1
OGP/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;
-}
+}