mirror of
https://github.com/tmux/tmux.git
synced 2025-01-14 12:48:56 +00:00
Trying to set FD_CLOEXEC on every fd is a lost cause, just use
closefrom() before exec.
This commit is contained in:
parent
6c42f1a89e
commit
f56b4ec2ff
2
client.c
2
client.c
@ -90,8 +90,6 @@ server_started:
|
||||
fatal("fcntl failed");
|
||||
if (fcntl(fd, F_SETFL, mode|O_NONBLOCK) == -1)
|
||||
fatal("fcntl failed");
|
||||
if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
|
||||
fatal("fcntl failed");
|
||||
imsg_init(&client_ibuf, fd);
|
||||
event_set(&client_event, fd, EV_READ, client_callback, NULL);
|
||||
|
||||
|
@ -112,6 +112,8 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||
if (null_fd != STDOUT_FILENO && null_fd != STDERR_FILENO)
|
||||
close(null_fd);
|
||||
|
||||
closefrom(STDERR_FILENO + 1);
|
||||
|
||||
command = status_replace(c, NULL, data->arg, time(NULL), 0);
|
||||
execl(_PATH_BSHELL, "sh", "-c", command, (char *) NULL);
|
||||
_exit(1);
|
||||
@ -130,8 +132,6 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||
fatal("fcntl failed");
|
||||
if (fcntl(wp->pipe_fd, F_SETFL, mode|O_NONBLOCK) == -1)
|
||||
fatal("fcntl failed");
|
||||
if (fcntl(wp->pipe_fd, F_SETFD, FD_CLOEXEC) == -1)
|
||||
fatal("fcntl failed");
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
4
job.c
4
job.c
@ -169,6 +169,8 @@ job_run(struct job *job)
|
||||
if (nullfd != STDIN_FILENO && nullfd != STDERR_FILENO)
|
||||
close(nullfd);
|
||||
|
||||
closefrom(STDERR_FILENO + 1);
|
||||
|
||||
execl(_PATH_BSHELL, "sh", "-c", job->cmd, (char *) NULL);
|
||||
fatal("execl failed");
|
||||
default: /* parent */
|
||||
@ -179,8 +181,6 @@ job_run(struct job *job)
|
||||
fatal("fcntl failed");
|
||||
if (fcntl(job->fd, F_SETFL, mode|O_NONBLOCK) == -1)
|
||||
fatal("fcntl failed");
|
||||
if (fcntl(job->fd, F_SETFD, FD_CLOEXEC) == -1)
|
||||
fatal("fcntl failed");
|
||||
|
||||
if (job->event != NULL)
|
||||
bufferevent_free(job->event);
|
||||
|
@ -60,8 +60,6 @@ server_client_create(int fd)
|
||||
fatal("fcntl failed");
|
||||
if (fcntl(fd, F_SETFL, mode|O_NONBLOCK) == -1)
|
||||
fatal("fcntl failed");
|
||||
if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
|
||||
fatal("fcntl failed");
|
||||
|
||||
c = xcalloc(1, sizeof *c);
|
||||
c->references = 0;
|
||||
@ -706,8 +704,6 @@ server_client_msg_dispatch(struct client *c)
|
||||
|
||||
if ((mode = fcntl(c->stdin_fd, F_GETFL)) != -1)
|
||||
fcntl(c->stdin_fd, F_SETFL, mode|O_NONBLOCK);
|
||||
if (fcntl(c->stdin_fd, F_SETFD, FD_CLOEXEC) == -1)
|
||||
fatal("fcntl failed");
|
||||
|
||||
server_client_msg_identify(c, &identifydata, imsg.fd);
|
||||
break;
|
||||
@ -725,8 +721,6 @@ server_client_msg_dispatch(struct client *c)
|
||||
|
||||
if ((mode = fcntl(c->stdout_fd, F_GETFL)) != -1)
|
||||
fcntl(c->stdout_fd, F_SETFL, mode|O_NONBLOCK);
|
||||
if (fcntl(c->stdout_fd, F_SETFD, FD_CLOEXEC) == -1)
|
||||
fatal("fcntl failed");
|
||||
break;
|
||||
case MSG_STDERR:
|
||||
if (datalen != 0)
|
||||
@ -742,8 +736,6 @@ server_client_msg_dispatch(struct client *c)
|
||||
|
||||
if ((mode = fcntl(c->stderr_fd, F_GETFL)) != -1)
|
||||
fcntl(c->stderr_fd, F_SETFL, mode|O_NONBLOCK);
|
||||
if (fcntl(c->stderr_fd, F_SETFD, FD_CLOEXEC) == -1)
|
||||
fatal("fcntl failed");
|
||||
break;
|
||||
case MSG_RESIZE:
|
||||
if (datalen != 0)
|
||||
|
2
server.c
2
server.c
@ -98,8 +98,6 @@ server_create_socket(void)
|
||||
fatal("fcntl failed");
|
||||
if (fcntl(fd, F_SETFL, mode|O_NONBLOCK) == -1)
|
||||
fatal("fcntl failed");
|
||||
if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
|
||||
fatal("fcntl failed");
|
||||
|
||||
server_update_socket();
|
||||
|
||||
|
2
tmux.c
2
tmux.c
@ -223,6 +223,8 @@ shell_exec(const char *shell, const char *shellcmd)
|
||||
xasprintf(&argv0, "%s", shellname);
|
||||
setenv("SHELL", shell, 1);
|
||||
|
||||
closefrom(STDERR_FILENO + 1);
|
||||
|
||||
execl(shell, argv0, "-c", shellcmd, (char *) NULL);
|
||||
fatal("execl failed");
|
||||
}
|
||||
|
3
tty.c
3
tty.c
@ -61,9 +61,6 @@ tty_init(struct tty *tty, int fd, char *term)
|
||||
tty->termname = xstrdup("unknown");
|
||||
else
|
||||
tty->termname = xstrdup(term);
|
||||
|
||||
if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
|
||||
fatal("fcntl failed");
|
||||
tty->fd = fd;
|
||||
|
||||
if ((path = ttyname(fd)) == NULL)
|
||||
|
4
window.c
4
window.c
@ -573,6 +573,8 @@ window_pane_spawn(struct window_pane *wp, const char *cmd, const char *shell,
|
||||
if (tcsetattr(STDIN_FILENO, TCSANOW, &tio2) != 0)
|
||||
fatal("tcgetattr failed");
|
||||
|
||||
closefrom(STDERR_FILENO + 1);
|
||||
|
||||
environ_push(env);
|
||||
|
||||
clear_signals(1);
|
||||
@ -603,8 +605,6 @@ window_pane_spawn(struct window_pane *wp, const char *cmd, const char *shell,
|
||||
fatal("fcntl failed");
|
||||
if (fcntl(wp->fd, F_SETFL, mode|O_NONBLOCK) == -1)
|
||||
fatal("fcntl failed");
|
||||
if (fcntl(wp->fd, F_SETFD, FD_CLOEXEC) == -1)
|
||||
fatal("fcntl failed");
|
||||
wp->event = bufferevent_new(wp->fd,
|
||||
window_pane_read_callback, NULL, window_pane_error_callback, wp);
|
||||
bufferevent_enable(wp->event, EV_READ|EV_WRITE);
|
||||
|
Loading…
Reference in New Issue
Block a user