From 31954339d1487d2a179f6180867e67cbd22aabd1 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Sat, 16 Oct 2010 08:42:35 +0000 Subject: [PATCH] Make stdio blocking again before calling shell command with -c. --- tmux.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tmux.c b/tmux.c index fe1fd394..f6601cdf 100644 --- a/tmux.c +++ b/tmux.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -211,6 +212,7 @@ shell_exec(const char *shell, const char *shellcmd) { const char *shellname, *ptr; char *argv0; + int mode; ptr = strrchr(shell, '/'); if (ptr != NULL && *(ptr + 1) != '\0') @@ -223,6 +225,12 @@ shell_exec(const char *shell, const char *shellcmd) xasprintf(&argv0, "%s", shellname); setenv("SHELL", shell, 1); + if ((mode = fcntl(STDIN_FILENO, F_GETFL)) != -1) + fcntl(STDIN_FILENO, F_SETFL, mode & ~O_NONBLOCK); + if ((mode = fcntl(STDOUT_FILENO, F_GETFL)) != -1) + fcntl(STDOUT_FILENO, F_SETFL, mode & ~O_NONBLOCK); + if ((mode = fcntl(STDERR_FILENO, F_GETFL)) != -1) + fcntl(STDERR_FILENO, F_SETFL, mode & ~O_NONBLOCK); closefrom(STDERR_FILENO + 1); execl(shell, argv0, "-c", shellcmd, (char *) NULL);