summaryrefslogtreecommitdiff
path: root/gio/gsubprocess.c
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2017-09-29 10:12:01 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2017-09-29 10:13:05 +0900
commit51fb06e60e7ca632ab70a0343d0012cbd509a2d7 (patch)
tree92a5a8b7577285c6eb0d579293e1b88cbff0881b /gio/gsubprocess.c
parentdbacddd04e38d963b1e89053af0433b045d59c17 (diff)
downloadglib-51fb06e60e7ca632ab70a0343d0012cbd509a2d7.tar.gz
glib-51fb06e60e7ca632ab70a0343d0012cbd509a2d7.tar.bz2
glib-51fb06e60e7ca632ab70a0343d0012cbd509a2d7.zip
Imported Upstream version 2.53.5
Change-Id: Ic5ebea56d852bf73b3c52afe342819e339412ef9 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'gio/gsubprocess.c')
-rw-r--r--gio/gsubprocess.c46
1 files changed, 33 insertions, 13 deletions
diff --git a/gio/gsubprocess.c b/gio/gsubprocess.c
index e3c43b04e..350eb1e93 100644
--- a/gio/gsubprocess.c
+++ b/gio/gsubprocess.c
@@ -199,36 +199,49 @@ unset_cloexec (int fd)
if (flags != -1)
{
+ int errsv;
flags &= (~FD_CLOEXEC);
do
- result = fcntl (fd, F_SETFD, flags);
- while (result == -1 && errno == EINTR);
+ {
+ result = fcntl (fd, F_SETFD, flags);
+ errsv = errno;
+ }
+ while (result == -1 && errsv == EINTR);
}
}
static int
dupfd_cloexec (int parent_fd)
{
- int fd;
+ int fd, errsv;
#ifdef F_DUPFD_CLOEXEC
do
- fd = fcntl (parent_fd, F_DUPFD_CLOEXEC, 3);
- while (fd == -1 && errno == EINTR);
+ {
+ fd = fcntl (parent_fd, F_DUPFD_CLOEXEC, 3);
+ errsv = errno;
+ }
+ while (fd == -1 && errsv == EINTR);
#else
/* OS X Snow Lion and earlier don't have F_DUPFD_CLOEXEC:
* https://bugzilla.gnome.org/show_bug.cgi?id=710962
*/
int result, flags;
do
- fd = fcntl (parent_fd, F_DUPFD, 3);
- while (fd == -1 && errno == EINTR);
+ {
+ fd = fcntl (parent_fd, F_DUPFD, 3);
+ errsv = errno;
+ }
+ while (fd == -1 && errsv == EINTR);
flags = fcntl (fd, F_GETFD, 0);
if (flags != -1)
{
flags |= FD_CLOEXEC;
do
- result = fcntl (fd, F_SETFD, flags);
- while (result == -1 && errno == EINTR);
+ {
+ result = fcntl (fd, F_SETFD, flags);
+ errsv = errno;
+ }
+ while (result == -1 && errsv == EINTR);
}
#endif
return fd;
@@ -245,6 +258,7 @@ child_setup (gpointer user_data)
ChildData *child_data = user_data;
gint i;
gint result;
+ int errsv;
/* We're on the child side now. "Rename" the file descriptors in
* child_data.fds[] to stdin/stdout/stderr.
@@ -257,8 +271,11 @@ child_setup (gpointer user_data)
if (child_data->fds[i] != -1 && child_data->fds[i] != i)
{
do
- result = dup2 (child_data->fds[i], i);
- while (result == -1 && errno == EINTR);
+ {
+ result = dup2 (child_data->fds[i], i);
+ errsv = errno;
+ }
+ while (result == -1 && errsv == EINTR);
}
/* Basic fd assignments we can just unset FD_CLOEXEC */
@@ -301,8 +318,11 @@ child_setup (gpointer user_data)
else
{
do
- result = dup2 (parent_fd, child_fd);
- while (result == -1 && errno == EINTR);
+ {
+ result = dup2 (parent_fd, child_fd);
+ errsv = errno;
+ }
+ while (result == -1 && errsv == EINTR);
(void) close (parent_fd);
}
}