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



commit 88558599eaf19999b8d595943390c20df4bd0afb
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 5f16708aa..1412cc11e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -172,6 +172,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[])
@@ -185,7 +198,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]