diff options
author | Tiago Cunha <tcunha@gmx.com> | 2010-10-24 00:47:46 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2010-10-24 00:47:46 +0000 |
commit | f79b467dceecfae493d8ddaabd1199566a68c910 (patch) | |
tree | 56a60dc1e406437a65973198c4bda5e02af2515b | |
parent | d4b58c71a21b1f380612eb0e45b312e4c91e2a95 (diff) |
Sync OpenBSD patchset 776:
Make stdio blocking again before calling shell command with -c.
-rw-r--r-- | tmux.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -1,4 +1,4 @@ -/* $Id: tmux.c,v 1.218 2010-10-24 00:45:57 tcunha 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 <pwd.h> #include <signal.h> #include <stdlib.h> @@ -214,6 +215,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') @@ -226,6 +228,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); |