Set the stdin pipe to non-blocking
continuous-integration/drone/push Build is passing Details

pull/3/head
Clément FRÉVILLE 2 years ago
parent 60b4fce341
commit c5913c7cc9

@ -2,6 +2,7 @@
#include <array>
#include <cerrno>
#include <fcntl.h>
#include <poll.h>
#include <spawn.h>
#include <system_error>
@ -19,6 +20,10 @@ run_result runner::run_blocking(const program &program) {
throw std::system_error{errno, std::generic_category()};
}
// Avoid blocking on stdin, and being interrupted if the pipe is closed prematurely
int flags = fcntl(in_pipe[1], F_GETFL, 0);
fcntl(in_pipe[1], F_SETFL, flags | O_NONBLOCK);
posix_spawn_file_actions_t actions;
posix_spawn_file_actions_init(&actions);
posix_spawn_file_actions_addclose(&actions, in_pipe[1]);

Loading…
Cancel
Save