mirror of
https://github.com/tmux/tmux.git
synced 2025-01-12 19:39:04 +00:00
Sync OpenBSD patchset 742:
dup() the stdin fd so it isn't closed twice (once for stdin, once for tty).
This commit is contained in:
parent
d7bae0edce
commit
4387db506f
@ -1,4 +1,4 @@
|
|||||||
/* $Id: server-client.c,v 1.37 2010-08-09 21:44:25 tcunha Exp $ */
|
/* $Id: server-client.c,v 1.38 2010-08-09 21:45:37 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -647,9 +647,11 @@ server_client_msg_dispatch(struct client *c)
|
|||||||
fatalx("MSG_IDENTIFY missing fd");
|
fatalx("MSG_IDENTIFY missing fd");
|
||||||
memcpy(&identifydata, imsg.data, sizeof identifydata);
|
memcpy(&identifydata, imsg.data, sizeof identifydata);
|
||||||
|
|
||||||
c->stdin_fd = imsg.fd;
|
c->stdin_fd = dup(imsg.fd);
|
||||||
c->stdin_event = bufferevent_new(imsg.fd, NULL, NULL,
|
if (c->stdin_fd == -1)
|
||||||
server_client_in_callback, c);
|
fatal("dup failed");
|
||||||
|
c->stdin_event = bufferevent_new(c->stdin_fd,
|
||||||
|
NULL, NULL, server_client_in_callback, c);
|
||||||
if (c->stdin_event == NULL)
|
if (c->stdin_event == NULL)
|
||||||
fatalx("failed to create stdin event");
|
fatalx("failed to create stdin event");
|
||||||
|
|
||||||
@ -667,14 +669,14 @@ server_client_msg_dispatch(struct client *c)
|
|||||||
fatalx("MSG_STDOUT missing fd");
|
fatalx("MSG_STDOUT missing fd");
|
||||||
|
|
||||||
c->stdout_fd = imsg.fd;
|
c->stdout_fd = imsg.fd;
|
||||||
c->stdout_event = bufferevent_new(imsg.fd, NULL, NULL,
|
c->stdout_event = bufferevent_new(c->stdout_fd,
|
||||||
server_client_out_callback, c);
|
NULL, NULL, server_client_out_callback, c);
|
||||||
if (c->stdout_event == NULL)
|
if (c->stdout_event == NULL)
|
||||||
fatalx("failed to create stdout event");
|
fatalx("failed to create stdout event");
|
||||||
|
|
||||||
if ((mode = fcntl(imsg.fd, F_GETFL)) != -1)
|
if ((mode = fcntl(c->stdout_fd, F_GETFL)) != -1)
|
||||||
fcntl(imsg.fd, F_SETFL, mode|O_NONBLOCK);
|
fcntl(c->stdout_fd, F_SETFL, mode|O_NONBLOCK);
|
||||||
if (fcntl(imsg.fd, F_SETFD, FD_CLOEXEC) == -1)
|
if (fcntl(c->stdout_fd, F_SETFD, FD_CLOEXEC) == -1)
|
||||||
fatal("fcntl failed");
|
fatal("fcntl failed");
|
||||||
break;
|
break;
|
||||||
case MSG_STDERR:
|
case MSG_STDERR:
|
||||||
@ -684,14 +686,14 @@ server_client_msg_dispatch(struct client *c)
|
|||||||
fatalx("MSG_STDERR missing fd");
|
fatalx("MSG_STDERR missing fd");
|
||||||
|
|
||||||
c->stderr_fd = imsg.fd;
|
c->stderr_fd = imsg.fd;
|
||||||
c->stderr_event = bufferevent_new(imsg.fd, NULL, NULL,
|
c->stderr_event = bufferevent_new(c->stderr_fd,
|
||||||
server_client_err_callback, c);
|
NULL, NULL, server_client_err_callback, c);
|
||||||
if (c->stderr_event == NULL)
|
if (c->stderr_event == NULL)
|
||||||
fatalx("failed to create stderr event");
|
fatalx("failed to create stderr event");
|
||||||
|
|
||||||
if ((mode = fcntl(imsg.fd, F_GETFL)) != -1)
|
if ((mode = fcntl(c->stderr_fd, F_GETFL)) != -1)
|
||||||
fcntl(imsg.fd, F_SETFL, mode|O_NONBLOCK);
|
fcntl(c->stderr_fd, F_SETFL, mode|O_NONBLOCK);
|
||||||
if (fcntl(imsg.fd, F_SETFD, FD_CLOEXEC) == -1)
|
if (fcntl(c->stderr_fd, F_SETFD, FD_CLOEXEC) == -1)
|
||||||
fatal("fcntl failed");
|
fatal("fcntl failed");
|
||||||
break;
|
break;
|
||||||
case MSG_RESIZE:
|
case MSG_RESIZE:
|
||||||
|
Loading…
Reference in New Issue
Block a user