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>
Thu, 27 Dec 2018 13:03:57 +0000 (13:03 +0000)
Fixes #11255.

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

src/udev/udev-event.c

index f601a0be5f8aab9434efa9669b3b5e7f24dda444..ebeae329a0df3fb4473f941d4ce3bd9128897ea9 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)