io: replace pipe() with g_unix_open_pipe(CLOEXEC)
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Fri, 22 Apr 2022 10:51:47 +0000 (14:51 +0400)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 3 May 2022 11:47:25 +0000 (15:47 +0400)
Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
io/channel-command.c

index 338da73ade56ad18813bacbdd04cde1d8200194d..539685ea83403013c05db5fb57ec88ec7ad271de 100644 (file)
@@ -76,8 +76,8 @@ qio_channel_command_new_spawn(const char *const argv[],
         }
     }
 
-    if ((!stdinnull && pipe(stdinfd) < 0) ||
-        (!stdoutnull && pipe(stdoutfd) < 0)) {
+    if ((!stdinnull && !g_unix_open_pipe(stdinfd, FD_CLOEXEC, NULL)) ||
+        (!stdoutnull && !g_unix_open_pipe(stdoutfd, FD_CLOEXEC, NULL))) {
         error_setg_errno(errp, errno,
                          "Unable to open pipe");
         goto error;