summaryrefslogtreecommitdiffstats
path: root/server.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2011-01-08 01:52:36 +0000
committerNicholas Marriott <nicm@openbsd.org>2011-01-08 01:52:36 +0000
commit69cb1f830e4fd2282ddcbc7ee2bbe30069b9e4cd (patch)
tree49efff28238bbba524974db0512859a310d0b09c /server.c
parent703160b5d6b64e45a684894260693c60b5524d51 (diff)
Move all calls to fcntl(...O_NONBLOCK) into a function and clear the
flag on the stdio file descriptors before closing them (fixes things like "tmux ls && cat").
Diffstat (limited to 'server.c')
-rw-r--r--server.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/server.c b/server.c
index 3b35454d..8f6ee149 100644
--- a/server.c
+++ b/server.c
@@ -74,7 +74,7 @@ server_create_socket(void)
struct sockaddr_un sa;
size_t size;
mode_t mask;
- int fd, mode;
+ int fd;
memset(&sa, 0, sizeof sa);
sa.sun_family = AF_UNIX;
@@ -95,11 +95,7 @@ server_create_socket(void)
if (listen(fd, 16) == -1)
fatal("listen failed");
-
- if ((mode = fcntl(fd, F_GETFL)) == -1)
- fatal("fcntl failed");
- if (fcntl(fd, F_SETFL, mode|O_NONBLOCK) == -1)
- fatal("fcntl failed");
+ setblocking(fd, 0);
server_update_socket();