diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2010-10-16 08:42:35 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2010-10-16 08:42:35 +0000 |
commit | 31954339d1487d2a179f6180867e67cbd22aabd1 (patch) | |
tree | 216d18aa2ad3e39a745d2446e4fb6e94be42fba5 /tmux.c | |
parent | f56b4ec2ffa6d5667a3bd86040a1c771c1de33a5 (diff) | |
download | rtmux-31954339d1487d2a179f6180867e67cbd22aabd1.tar.gz rtmux-31954339d1487d2a179f6180867e67cbd22aabd1.tar.bz2 rtmux-31954339d1487d2a179f6180867e67cbd22aabd1.zip |
Make stdio blocking again before calling shell command with -c.
Diffstat (limited to 'tmux.c')
-rw-r--r-- | tmux.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -22,6 +22,7 @@ #include <errno.h> #include <event.h> +#include <fcntl.h> #include <paths.h> #include <pwd.h> #include <signal.h> @@ -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); |