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

erinn at torproject.org erinn at torproject.org
Fri Mar 16 04:49:24 UTC 2012


commit 8dae8357a6426e41bbc24a10e02c8874ebedeb23
Author: Robert Ransom <rransom.8774 at gmail.com>
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
 





More information about the tor-commits mailing list