diff options
author | 2010-10-16 08:42:35 +0000 | |
---|---|---|
committer | 2010-10-16 08:42:35 +0000 | |
commit | 3808d149816c309556e05c2be79d090a9acc039d (patch) | |
tree | fb7b1a644327306a04e5acc419d133ba80114860 /usr.bin/tmux/tmux.c | |
parent | Trying to set FD_CLOEXEC on every fd is a lost cause, just use (diff) | |
download | wireguard-openbsd-3808d149816c309556e05c2be79d090a9acc039d.tar.xz wireguard-openbsd-3808d149816c309556e05c2be79d090a9acc039d.zip |
Make stdio blocking again before calling shell command with -c.
Diffstat (limited to 'usr.bin/tmux/tmux.c')
-rw-r--r-- | usr.bin/tmux/tmux.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c index 04119f5f5d8..95969506afc 100644 --- a/usr.bin/tmux/tmux.c +++ b/usr.bin/tmux/tmux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.c,v 1.90 2010/10/16 08:31:55 nicm Exp $ */ +/* $OpenBSD: tmux.c,v 1.91 2010/10/16 08:42:35 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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); |