udev-event: do not read stdout or stderr if the pipefd is not created
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 25 Dec 2018 15:36:55 +0000 (00:36 +0900)
committerMichael Biebl <biebl@debian.org>
Sat, 12 Jan 2019 20:49:44 +0000 (20:49 +0000)
Fixes #11255.

(cherry picked from commit adeb26c1affd09138bb96a9e25b795d146e64c97)
(cherry picked from commit 32a11a27b69031240beea38260d93e034ea33036)

Gbp-Pq: Name udev-event-do-not-read-stdout-or-stderr-if-the-pipefd-is-.patch

src/udev/udev-event.c

index e28d6a5d08b5a751d36dba6960974b72f783a9f2..3e916976c030bb0b792e616e6d6c270094dcebe5 100644 (file)
@@ -570,13 +570,17 @@ static int spawn_wait(Spawn *spawn) {
                 }
         }
 
-        r = sd_event_add_io(e, NULL, spawn->fd_stdout, EPOLLIN, on_spawn_io, spawn);
-        if (r < 0)
-                return r;
+        if (spawn->fd_stdout >= 0) {
+                r = sd_event_add_io(e, NULL, spawn->fd_stdout, EPOLLIN, on_spawn_io, spawn);
+                if (r < 0)
+                        return r;
+        }
 
-        r = sd_event_add_io(e, NULL, spawn->fd_stderr, EPOLLIN, on_spawn_io, spawn);
-        if (r < 0)
-                return r;
+        if (spawn->fd_stderr >= 0) {
+                r = sd_event_add_io(e, NULL, spawn->fd_stderr, EPOLLIN, on_spawn_io, spawn);
+                if (r < 0)
+                        return r;
+        }
 
         r = sd_event_add_child(e, NULL, spawn->pid, WEXITED, on_spawn_sigchld, spawn);
         if (r < 0)