[gnome-builder/gnome-builder-3-32] main: use stdin instead of stdout for terminal detection



commit 7292b8819b71db2753aa234c4043b3bc1a0cff1e
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jul 15 12:21:39 2019 -0700

    main: use stdin instead of stdout for terminal detection
    
    Related: #971

 src/main.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
---
diff --git a/src/main.c b/src/main.c
index cd3eeefaf..d230634ae 100644
--- a/src/main.c
+++ b/src/main.c
@@ -96,6 +96,19 @@ home_contains_symlink (void)
   return _home_contains_symlink (g_get_home_dir ());
 }
 
+static gboolean
+is_running_in_shell (void)
+{
+  /* If stdin is not a TTY, then assume we have no access to communicate
+   * with the user via console. We use stdin instead of stdout as a logging
+   * system may have a PTY for stdout to get colorized output.
+   */
+  if (!isatty (STDIN_FILENO))
+    return FALSE;
+
+  return TRUE;
+}
+
 gint
 main (gint   argc,
       gchar *argv[])
@@ -109,7 +122,7 @@ main (gint   argc,
   int ret;
 
   /* Setup our gdb fork()/exec() helper if we're in a terminal */
-  if (isatty (STDOUT_FILENO))
+  if (is_running_in_shell ())
     bug_buddy_init ();
 
   /* Always ignore SIGPIPE */


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