summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2010-10-24 00:47:46 +0000
committerTiago Cunha <tcunha@gmx.com>2010-10-24 00:47:46 +0000
commitf79b467dceecfae493d8ddaabd1199566a68c910 (patch)
tree56a60dc1e406437a65973198c4bda5e02af2515b
parentd4b58c71a21b1f380612eb0e45b312e4c91e2a95 (diff)
Sync OpenBSD patchset 776:
Make stdio blocking again before calling shell command with -c.
-rw-r--r--tmux.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/tmux.c b/tmux.c
index 49fba2ba..f380b1fe 100644
--- a/tmux.c
+++ b/tmux.c
@@ -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);