mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-03 09:46:17 +01:00
gspawn: Handle EINTR in a few more cases
I was debugging gthread/tests/spawn-multithreaded.c, and while I don't think I actually hit EINTR in any of these cases, it'd be good to fix them anyways. https://bugzilla.gnome.org/show_bug.cgi?id=652072
This commit is contained in:
parent
922f6aa496
commit
7e1886ba72
@ -148,7 +148,10 @@ close_and_invalidate (gint *fd)
|
|||||||
return -1;
|
return -1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
again:
|
||||||
ret = close (*fd);
|
ret = close (*fd);
|
||||||
|
if (ret == -1 && errno == EINTR)
|
||||||
|
goto again;
|
||||||
*fd = -1;
|
*fd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,10 +326,13 @@ g_spawn_sync (const gchar *working_directory,
|
|||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
NULL /* no timeout */);
|
NULL /* no timeout */);
|
||||||
|
|
||||||
if (ret < 0 && errno != EINTR)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
int errsv = errno;
|
int errsv = errno;
|
||||||
|
|
||||||
|
if (errno == EINTR)
|
||||||
|
continue;
|
||||||
|
|
||||||
failed = TRUE;
|
failed = TRUE;
|
||||||
|
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
@ -993,6 +999,19 @@ sane_dup2 (gint fd1, gint fd2)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gint
|
||||||
|
sane_open (const char *path, gint mode)
|
||||||
|
{
|
||||||
|
gint ret;
|
||||||
|
|
||||||
|
retry:
|
||||||
|
ret = open (path, mode);
|
||||||
|
if (ret < 0 && errno == EINTR)
|
||||||
|
goto retry;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
CHILD_CHDIR_FAILED,
|
CHILD_CHDIR_FAILED,
|
||||||
@ -1071,7 +1090,7 @@ do_exec (gint child_err_report_fd,
|
|||||||
}
|
}
|
||||||
else if (stdout_to_null)
|
else if (stdout_to_null)
|
||||||
{
|
{
|
||||||
gint write_null = open ("/dev/null", O_WRONLY);
|
gint write_null = sane_open ("/dev/null", O_WRONLY);
|
||||||
sane_dup2 (write_null, 1);
|
sane_dup2 (write_null, 1);
|
||||||
close_and_invalidate (&write_null);
|
close_and_invalidate (&write_null);
|
||||||
}
|
}
|
||||||
@ -1089,7 +1108,7 @@ do_exec (gint child_err_report_fd,
|
|||||||
}
|
}
|
||||||
else if (stderr_to_null)
|
else if (stderr_to_null)
|
||||||
{
|
{
|
||||||
gint write_null = open ("/dev/null", O_WRONLY);
|
gint write_null = sane_open ("/dev/null", O_WRONLY);
|
||||||
sane_dup2 (write_null, 2);
|
sane_dup2 (write_null, 2);
|
||||||
close_and_invalidate (&write_null);
|
close_and_invalidate (&write_null);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user