aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix')
-rw-r--r--sysdeps/unix/sysv/linux/spawni.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c
index c497869..353bcf5 100644
--- a/sysdeps/unix/sysv/linux/spawni.c
+++ b/sysdeps/unix/sysv/linux/spawni.c
@@ -253,9 +253,21 @@ __spawni_child (void *arguments)
break;
case spawn_do_dup2:
- if (__dup2 (action->action.dup2_action.fd,
- action->action.dup2_action.newfd)
- != action->action.dup2_action.newfd)
+ /* Austin Group issue #411 requires adddup2 action with source
+ and destination being equal to remove close-on-exec flag. */
+ if (action->action.dup2_action.fd
+ == action->action.dup2_action.newfd)
+ {
+ int fd = action->action.dup2_action.newfd;
+ int flags = __fcntl (fd, F_GETFD, 0);
+ if (flags == -1)
+ goto fail;
+ if (__fcntl (fd, F_SETFD, flags & ~FD_CLOEXEC) == -1)
+ goto fail;
+ }
+ else if (__dup2 (action->action.dup2_action.fd,
+ action->action.dup2_action.newfd)
+ != action->action.dup2_action.newfd)
goto fail;
break;