[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [torbrowser/maint-2.3] [4093 Linux Mac] Close non-TTY stdout and stderr when not in debug mode



commit 8dae8357a6426e41bbc24a10e02c8874ebedeb23
Author: Robert Ransom <rransom.8774@xxxxxxxxx>
Date:   Thu Mar 8 18:27:30 2012 -0800

    [4093 Linux Mac] Close non-TTY stdout and stderr when not in debug mode
---
 src/RelativeLink/RelativeLink.sh    |   18 ++++++++++++++++++
 src/RelativeLink/RelativeLinkOSX.sh |   18 ++++++++++++++++++
 2 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/src/RelativeLink/RelativeLink.sh b/src/RelativeLink/RelativeLink.sh
index eb0cb9d..053b471 100755
--- a/src/RelativeLink/RelativeLink.sh
+++ b/src/RelativeLink/RelativeLink.sh
@@ -123,6 +123,24 @@ elif [ "$#" -eq 1 -a \( "x$1" = "x--help" -o "x$1" = "x-help" \) ]; then
 	exit 0
 fi
 
+# If the user hasn't requested 'debug mode', close whichever of stdout
+# and stderr are not ttys, to keep Vidalia and the stuff loaded by/for
+# it (including the system's shared-library loader) from printing
+# messages to $HOME/.xsession-errors .  (Users wouldn't have seen
+# messages there anyway.)
+#
+# If the user has requested 'debug mode', don't muck with the FDs.
+if [ "$debug" -ne 1 ]; then
+  if [ '!' -t 1 ]; then
+    # stdout is not a tty
+    exec >/dev/null
+  fi
+  if [ '!' -t 2 ]; then
+    # stderr is not a tty
+    exec 2>/dev/null
+  fi
+fi
+
 # If XAUTHORITY is unset, set it to its default value of $HOME/.Xauthority
 # before we change HOME below.  (See xauth(1) and #1945.)  XDM and KDM rely
 # on applications using this default value.
diff --git a/src/RelativeLink/RelativeLinkOSX.sh b/src/RelativeLink/RelativeLinkOSX.sh
index e301483..63ec4fb 100755
--- a/src/RelativeLink/RelativeLinkOSX.sh
+++ b/src/RelativeLink/RelativeLinkOSX.sh
@@ -19,6 +19,24 @@ if [ "x$1" = "x--debug" -o "x$1" = "x-debug" ]; then
 	printf "\nDebug enabled.\n\n"
 fi
 
+# If the user hasn't requested 'debug mode', close whichever of stdout
+# and stderr are not ttys, to keep Vidalia and the stuff loaded by/for
+# it (including the system's shared-library loader) from printing
+# messages to be logged in /var/log/system.log .  (Users wouldn't have
+# seen messages there anyway.)
+#
+# If the user has requested 'debug mode', don't muck with the FDs.
+if [ "$DEBUG_TBB" -ne 1 ]; then
+  if [ '!' -t 1 ]; then
+    # stdout is not a tty
+    exec >/dev/null
+  fi
+  if [ '!' -t 2 ]; then
+    # stderr is not a tty
+    exec 2>/dev/null
+  fi
+fi
+
 HOME="${0%%Contents/MacOS/TorBrowserBundle}"
 export HOME
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits