]> git.ipfire.org Git - people/ms/pakfire.git/commitdiff
jail: epoll: Only register for the operations we actually need
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 16 Dec 2022 10:23:48 +0000 (10:23 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 16 Dec 2022 10:23:48 +0000 (10:23 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/jail.c

index c53dce03528e96f777039e9f67e78abe66b78d62..20785045e601479b0c565d6a609648d6b7c0086f 100644 (file)
@@ -641,8 +641,6 @@ static int pakfire_jail_wait(struct pakfire_jail* jail, struct pakfire_jail_exec
                goto ERROR;
        }
 
-       ev.events = EPOLLIN|EPOLLOUT|EPOLLHUP;
-
        // Turn file descriptors into non-blocking mode and add them to epoll()
        for (unsigned int i = 0; i < sizeof(fds) / sizeof(*fds); i++) {
                int fd = fds[i];
@@ -651,6 +649,13 @@ static int pakfire_jail_wait(struct pakfire_jail* jail, struct pakfire_jail_exec
                if (fd <= 0)
                        continue;
 
+               ev.events = EPOLLHUP;
+
+               if (fd == stdin)
+                       ev.events |= EPOLLOUT;
+               else
+                       ev.events |= EPOLLIN;
+
                // Read flags
                int flags = fcntl(fd, F_GETFL, 0);