From 1e379eed53e4be43ddbedccf8087b3821e3937e3 Mon Sep 17 00:00:00 2001 From: monojenkins Date: Tue, 25 Feb 2020 13:54:45 -0500 Subject: [PATCH] Change macro CLOSE_PIPE to function mono_close_pipe. (#32793) Extracted from https://github.com/mono/mono/pull/19025. Co-authored-by: Jay Krell --- src/mono/mono/eglib/gspawn.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/mono/mono/eglib/gspawn.c b/src/mono/mono/eglib/gspawn.c index 64ac161..0f30bc3 100644 --- a/src/mono/mono/eglib/gspawn.c +++ b/src/mono/mono/eglib/gspawn.c @@ -72,7 +72,13 @@ #define set_error_cond(cond,msg, ...) do { if ((cond) && gerror != NULL) *gerror = g_error_new (G_LOG_DOMAIN, 1, msg, __VA_ARGS__); } while (0) #define set_error_status(status,msg, ...) do { if (gerror != NULL) *gerror = g_error_new (G_LOG_DOMAIN, status, msg, __VA_ARGS__); } while (0) #define NO_INTR(var,cmd) do { (var) = (cmd); } while ((var) == -1 && errno == EINTR) -#define CLOSE_PIPE(p) do { close (p [0]); close (p [1]); } while (0) + +static void +mono_close_pipe (int p [2]) +{ + close (p [0]); + close (p [1]); +} #if defined(__APPLE__) #if defined (TARGET_OSX) @@ -269,7 +275,7 @@ g_spawn_command_line_sync (const gchar *command_line, if (standard_error && !create_pipe (stderr_pipe, gerror)) { if (standard_output) { - CLOSE_PIPE (stdout_pipe); + mono_close_pipe (stdout_pipe); } return FALSE; } @@ -366,29 +372,29 @@ g_spawn_async_with_pipes (const gchar *working_directory, return FALSE; if (standard_output && !create_pipe (out_pipe, gerror)) { - CLOSE_PIPE (info_pipe); + mono_close_pipe (info_pipe); return FALSE; } if (standard_error && !create_pipe (err_pipe, gerror)) { - CLOSE_PIPE (info_pipe); - CLOSE_PIPE (out_pipe); + mono_close_pipe (info_pipe); + mono_close_pipe (out_pipe); return FALSE; } if (standard_input && !create_pipe (in_pipe, gerror)) { - CLOSE_PIPE (info_pipe); - CLOSE_PIPE (out_pipe); - CLOSE_PIPE (err_pipe); + mono_close_pipe (info_pipe); + mono_close_pipe (out_pipe); + mono_close_pipe (err_pipe); return FALSE; } pid = fork (); if (pid == -1) { - CLOSE_PIPE (info_pipe); - CLOSE_PIPE (out_pipe); - CLOSE_PIPE (err_pipe); - CLOSE_PIPE (in_pipe); + mono_close_pipe (info_pipe); + mono_close_pipe (out_pipe); + mono_close_pipe (err_pipe); + mono_close_pipe (in_pipe); set_error ("%s", "Error in fork ()"); return FALSE; } @@ -483,10 +489,10 @@ g_spawn_async_with_pipes (const gchar *working_directory, /* Wait for the first child if two are created */ NO_INTR (w, waitpid (pid, &status, 0)); if (status == 1 || w == -1) { - CLOSE_PIPE (info_pipe); - CLOSE_PIPE (out_pipe); - CLOSE_PIPE (err_pipe); - CLOSE_PIPE (in_pipe); + mono_close_pipe (info_pipe); + mono_close_pipe (out_pipe); + mono_close_pipe (err_pipe); + mono_close_pipe (in_pipe); set_error ("Error in fork (): %d", status); return FALSE; } -- 2.7.4