]> git.ipfire.org Git - pakfire.git/commitdiff
jail: Create fds for logging as non-blocking straight away
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 3 Aug 2022 09:01:38 +0000 (09:01 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 3 Aug 2022 09:01:38 +0000 (09:01 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/jail.c

index 1b44b112abedc71f85ee79e3efcaf83b6b84020b..07f4d4e89837412387f2164c9248b69fccbadbf6 100644 (file)
@@ -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;