summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/tmux/client.c4
-rw-r--r--usr.bin/tmux/cmd-pipe-pane.c6
-rw-r--r--usr.bin/tmux/job.c6
-rw-r--r--usr.bin/tmux/server-client.c10
-rw-r--r--usr.bin/tmux/server.c4
-rw-r--r--usr.bin/tmux/tmux.c4
-rw-r--r--usr.bin/tmux/tty.c5
-rw-r--r--usr.bin/tmux/window.c6
8 files changed, 16 insertions, 29 deletions
diff --git a/usr.bin/tmux/client.c b/usr.bin/tmux/client.c
index bbd0ae03999..c71c510abfb 100644
--- a/usr.bin/tmux/client.c
+++ b/usr.bin/tmux/client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: client.c,v 1.44 2010/08/23 17:36:32 nicm Exp $ */
+/* $OpenBSD: client.c,v 1.45 2010/10/16 08:31:55 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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);
diff --git a/usr.bin/tmux/cmd-pipe-pane.c b/usr.bin/tmux/cmd-pipe-pane.c
index 85dda3d6b8d..592cb1e2d83 100644
--- a/usr.bin/tmux/cmd-pipe-pane.c
+++ b/usr.bin/tmux/cmd-pipe-pane.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-pipe-pane.c,v 1.15 2010/08/19 18:29:01 nicm Exp $ */
+/* $OpenBSD: cmd-pipe-pane.c,v 1.16 2010/10/16 08:31:55 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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);
}
}
diff --git a/usr.bin/tmux/job.c b/usr.bin/tmux/job.c
index e540e41d367..7313fa76105 100644
--- a/usr.bin/tmux/job.c
+++ b/usr.bin/tmux/job.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: job.c,v 1.20 2010/08/19 18:29:01 nicm Exp $ */
+/* $OpenBSD: job.c,v 1.21 2010/10/16 08:31:55 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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);
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c
index 21c22b4c8a7..d2d8932effc 100644
--- a/usr.bin/tmux/server-client.c
+++ b/usr.bin/tmux/server-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server-client.c,v 1.41 2010/09/26 20:43:30 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.42 2010/10/16 08:31:55 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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)
diff --git a/usr.bin/tmux/server.c b/usr.bin/tmux/server.c
index f13b3b98bd2..3b337648a6d 100644
--- a/usr.bin/tmux/server.c
+++ b/usr.bin/tmux/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.94 2010/09/26 20:43:30 nicm Exp $ */
+/* $OpenBSD: server.c,v 1.95 2010/10/16 08:31:55 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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();
diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c
index bf8883276d4..04119f5f5d8 100644
--- a/usr.bin/tmux/tmux.c
+++ b/usr.bin/tmux/tmux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.c,v 1.89 2010/10/14 17:38:39 nicm Exp $ */
+/* $OpenBSD: tmux.c,v 1.90 2010/10/16 08:31:55 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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");
}
diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c
index cdbc37986be..1ba18b1504f 100644
--- a/usr.bin/tmux/tty.c
+++ b/usr.bin/tmux/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.91 2010/09/11 16:20:58 nicm Exp $ */
+/* $OpenBSD: tty.c,v 1.92 2010/10/16 08:31:55 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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)
diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c
index a7549d086de..14749553eec 100644
--- a/usr.bin/tmux/window.c
+++ b/usr.bin/tmux/window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window.c,v 1.55 2010/08/25 19:19:43 nicm Exp $ */
+/* $OpenBSD: window.c,v 1.56 2010/10/16 08:31:55 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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);