#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)
if (standard_error && !create_pipe (stderr_pipe, gerror)) {
if (standard_output) {
- CLOSE_PIPE (stdout_pipe);
+ mono_close_pipe (stdout_pipe);
}
return FALSE;
}
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;
}
/* 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;
}