/* stdin- and SIGCHLD-watchers */
ev_io *stdin_io;
+int stdin_fd;
ev_child *child_sig;
/* JSON parser for stdin */
}
free(buffer);
ev_io_stop(main_loop, stdin_io);
- ev_io_init(stdin_io, &stdin_io_cb, STDIN_FILENO, EV_READ);
+ ev_io_init(stdin_io, &stdin_io_cb, stdin_fd, EV_READ);
ev_io_start(main_loop, stdin_io);
}
close(pipe_in[1]);
close(pipe_out[0]);
- dup2(pipe_in[0], STDIN_FILENO);
+ stdin_fd = pipe_in[0];
child_stdin = pipe_out[1];
break;
}
/* We set O_NONBLOCK because blocking is evil in event-driven software */
- fcntl(STDIN_FILENO, F_SETFL, O_NONBLOCK);
+ fcntl(stdin_fd, F_SETFL, O_NONBLOCK);
stdin_io = smalloc(sizeof(ev_io));
- ev_io_init(stdin_io, &stdin_io_first_line_cb, STDIN_FILENO, EV_READ);
+ ev_io_init(stdin_io, &stdin_io_first_line_cb, stdin_fd, EV_READ);
ev_io_start(main_loop, stdin_io);
/* We must cleanup, if the child unexpectedly terminates */