--- x2gocleansessions.orig	2014-10-07 00:05:56.000000000 -0400
+++ x2gocleansessions	2014-11-20 10:21:56.312590068 -0500
@@ -130,23 +130,21 @@
 	# close any open file descriptor left open by our parent before the fork
 	my $fd;
 	for (glob "/proc/$$/fd/*") {
-		if ($_ =~ m/\/proc\/(\d+)\/fd\/(\d+)/) {
-			$fd = $2;
-			if ( $fd == 0 ) { next; }
-			if ( $fd == 1 ) { next; }
-			if (POSIX::close($fd)) {
-				print "";
-				#print "Closed:II$_\n";
-			} else {
-				print "";
-				#print "Error Closing:I$_\n";
+		if ( ! -e $_ ) { next; }
+		if ($_ =~ m/\/proc\/\d+\/fd\/(\d+)/) {
+			$fd = $1;
+			if ( $fd < 3 ) { next; }
+			if (! POSIX::close($fd)) {
+				syslog('warning', "Error Closing $_: $!");
 			}
-		} else {
-			print "";
-			#print "ERROR: $_\n";
 		}
 	}
 
+	# redirect stdin, stdout and stderr
+	open *STDIN, q{<}, '/dev/null';
+	open *STDOUT, q{>>}, '/dev/null';
+	open *STDERR, q{>>}, '/dev/null';
+
 	$SIG{TERM}=\&catch_term;
 	$SIG{CHLD} = sub { wait };
 
