mirror of
https://github.com/tmux/tmux.git
synced 2024-11-18 10:28:54 +00:00
Sync OpenBSD patchset 776:
Make stdio blocking again before calling shell command with -c.
This commit is contained in:
parent
d4b58c71a2
commit
f79b467dce
10
tmux.c
10
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);
|
||||
|
Loading…
Reference in New Issue
Block a user