# HG changeset patch
# User Fabian Groffen <[email protected]>
# Date 1382887896 -3600
#      Sun Oct 27 16:31:36 2013 +0100
# Branch gentoo-1.5.22
# Node ID 3dd52e1999da1e17cfccca54a24a5365ef5d9644
# Parent  47fe4a09fcb9ae3c6b7563ba148001e3b86d6e58
xterm: check we're on a tty before calling tigetstr

tigetstr appears to spinlock/hang when called without a tty, which is
undesirable when mutt is ran from cron or ssh in a scripted fashion,
e.g. to send mail.  Hence, abort early if stdout doesn't appear to be
connected to a tty.
Fixes https://bugs.gentoo.org/show_bug.cgi?id=432562

diff --git a/curs_main.c b/curs_main.c
--- a/curs_main.c
+++ b/curs_main.c
@@ -134,6 +134,11 @@ short mutt_ts_capability(void)
     NULL
   };
 
+  /* check that we're actually having a tty, such that tigetstr doesn't
+   * hang/spinlock */
+  if (!isatty(1))
+    return 0;
+
   /* If tsl is set, then terminfo says that status lines work. */
   tcaps = tigetstr("tsl");
   if (tcaps && tcaps != (char *)-1 && *tcaps)

Reply via email to