From 521cc806fbea69817cbb32da0af3a3e4be51da83 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Thu, 10 Mar 2016 21:42:58 -0800 Subject: [PATCH] Apparently programs expect their stdin to be blocking --- adsbus/exec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/adsbus/exec.c b/adsbus/exec.c index c8cc403..4108f52 100644 --- a/adsbus/exec.c +++ b/adsbus/exec.c @@ -127,6 +127,9 @@ static void exec_parent(struct exec *exec, pid_t child, int data_fd, int log_fd) exec->child = child; LOG(exec->id, "Child started as process %d", exec->child); + assert(!fcntl(data_fd, F_SETFL, O_NONBLOCK)); + assert(!fcntl(log_fd, F_SETFL, O_NONBLOCK)); + exec->log_peer.fd = log_fd; exec->log_peer.event_handler = exec_log_handler; peer_epoll_add(&exec->log_peer, EPOLLIN); @@ -167,8 +170,8 @@ static void __attribute__ ((noreturn)) exec_child(const struct exec *exec, int d static void exec_spawn(struct exec *exec) { LOG(exec->id, "Executing: %s", exec->command); int data_fds[2], log_fds[2]; - assert(!socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0, data_fds)); - assert(!socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0, log_fds)); + assert(!socketpair(AF_UNIX, SOCK_STREAM, 0, data_fds)); + assert(!socketpair(AF_UNIX, SOCK_STREAM, 0, log_fds)); assert(!fcntl(data_fds[0], F_SETFD, FD_CLOEXEC)); assert(!fcntl(log_fds[0], F_SETFD, FD_CLOEXEC));