From: Michael Tremer Date: Wed, 3 Aug 2022 09:01:38 +0000 (+0000) Subject: jail: Create fds for logging as non-blocking straight away X-Git-Tag: 0.9.28~607 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=41451d73375877e8becdeddadde9032772c7f03c;p=pakfire.git jail: Create fds for logging as non-blocking straight away Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/jail.c b/src/libpakfire/jail.c index 1b44b112a..07f4d4e89 100644 --- a/src/libpakfire/jail.c +++ b/src/libpakfire/jail.c @@ -430,17 +430,6 @@ static int pakfire_jail_logger(struct pakfire_jail* jail, struct pakfire_jail_ex for (unsigned int i = 0; i < 2; i++) { int fd = fds[i]; - // Read flags - int flags = fcntl(fd, F_GETFL, 0); - - // Set modified flags - if (fcntl(fd, F_SETFL, flags|O_NONBLOCK) < 0) { - ERROR(jail->pakfire, - "Could not set file descriptor %d into non-blocking mode: %m\n", fd); - r = 1; - goto OUT; - } - ev.data.fd = fd; if (epoll_ctl(epollfd, EPOLL_CTL_ADD, fd, &ev) < 0) { @@ -993,14 +982,14 @@ int pakfire_jail_exec(struct pakfire_jail* jail, const char* argv[]) { // Create pipes to communicate with child process if we are not running interactively if (!pakfire_jail_has_flag(jail, PAKFIRE_JAIL_INTERACTIVE)) { // stdout - r = pipe(ctx.pipes.stdout); + r = pipe2(ctx.pipes.stdout, O_NONBLOCK); if (r < 0) { ERROR(jail->pakfire, "Could not create file descriptors for stdout: %m\n"); goto ERROR; } // stderr - r = pipe(ctx.pipes.stderr); + r = pipe2(ctx.pipes.stderr, O_NONBLOCK); if (r < 0) { ERROR(jail->pakfire, "Could not create file descriptors for stderr: %m\n"); goto ERROR;