From 84b704b21bb61098b31694c68092230d48445e75 Mon Sep 17 00:00:00 2001 From: Joshua Judson Rosen Date: Sat, 1 Apr 2017 21:42:55 -0400 Subject: ui-cmdwin: prevent excessive buffering on captured stdio streams Streams that start out connected to non-tty FDs default to fully-buffered and retain that configuration after those underlying FDs are redirected, which prevents the "need to run from an xterm" fix from actually working unless we do something like this to reset the stream buffers. --- src/ui-cmdwin.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ui-cmdwin.c b/src/ui-cmdwin.c index f48e72f..f663aa1 100644 --- a/src/ui-cmdwin.c +++ b/src/ui-cmdwin.c @@ -56,6 +56,14 @@ static void ui_cmdwin_init(UICmdWin *cmdwin) dup2(slave_pty, 1); dup2(slave_pty, 2); + /* Explicitly set stdio streams into line-buffered mode, + in case they were initially connected to non-tty FDs + (as is probably the case if we were started from a GUI launcher), + in which case they'd be in fully-buffered mode by default... */ + fflush (stdin); setlinebuf (stdin); + fflush (stdout); setlinebuf (stdout); + fflush (stderr); setlinebuf (stderr); + vte_terminal_set_pty(VTE_TERMINAL(cmdwin->priv->vte), master_pty); gtk_widget_show(cmdwin->priv->vte); -- cgit v1.1