diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2017-04-21 10:40:56 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2017-04-25 08:51:12 -0300 |
commit | daeb1fa2e1b33323e719015f5f546988bd4cc73b (patch) | |
tree | c09f990c8f116d298a1168c6b9620d94cb2ba1c1 /sysdeps | |
parent | 9581e76dbb4a8dad8a4493ef6833685153edd1d9 (diff) | |
download | glibc-daeb1fa2e1b33323e719015f5f546988bd4cc73b.zip glibc-daeb1fa2e1b33323e719015f5f546988bd4cc73b.tar.gz glibc-daeb1fa2e1b33323e719015f5f546988bd4cc73b.tar.bz2 |
[BZ 21340] add support for POSIX_SPAWN_SETSID
This patch adds support for the POSIX_SPAWN_SETSID flag.
It was recently accepted by the Austin Group:
http://austingroupbugs.net/view.php?id=1044
Checked on x86_64
Daurnimator <quae@daurnimator.com>
Adhemerval Zanella <adhemerval.zanella@linaro.org>
[BZ #21340]
* posix/Makefile (tests): Add tst-posix_spawn-setsid to list of tests.
* posix/spawn.h: define POSIX_SPAWN_SETSID flag.
* posix/spawnattr_setflags.c (ALL_FLAGS): Add POSIX_SPAWN_SETSID to
valid flags.
* posix/tst-posix_spawn-setsid.c: Add test for POSIX_SPAWN_SETSID.
* sysdeps/mach/hurd/spawni.c (__spawni): Implementation of
POSIX_SPAWN_SETSID.
* sysdeps/posix/spawni.c (__spawni): Likewise.
* sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Likewise.
* NEWS: Add note about POSIX_SPAWN_SETSID support.
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/mach/hurd/spawni.c | 3 | ||||
-rw-r--r-- | sysdeps/posix/spawni.c | 7 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/spawni.c | 4 |
3 files changed, 13 insertions, 1 deletions
diff --git a/sysdeps/mach/hurd/spawni.c b/sysdeps/mach/hurd/spawni.c index 284875a..7430383 100644 --- a/sysdeps/mach/hurd/spawni.c +++ b/sysdeps/mach/hurd/spawni.c @@ -281,6 +281,9 @@ __spawni (pid_t *pid, const char *file, } #endif + if (!err && (flags & POSIX_SPAWN_SETSID) != 0) + err = __proc_setsid (proc); + /* Set the process group ID. */ if (!err && (flags & POSIX_SPAWN_SETPGROUP) != 0) err = __proc_setpgrp (proc, new_pid, attrp->__pgrp); diff --git a/sysdeps/posix/spawni.c b/sysdeps/posix/spawni.c index 5cc2ad1..9cad25c 100644 --- a/sysdeps/posix/spawni.c +++ b/sysdeps/posix/spawni.c @@ -101,7 +101,8 @@ __spawni (pid_t *pid, const char *file, to POSIX. */ || ((flags & (POSIX_SPAWN_SETSIGMASK | POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETSCHEDULER - | POSIX_SPAWN_SETPGROUP | POSIX_SPAWN_RESETIDS)) == 0 + | POSIX_SPAWN_SETPGROUP | POSIX_SPAWN_RESETIDS + | POSIX_SPAWN_SETSID)) == 0 && file_actions == NULL)) new_pid = __vfork (); else @@ -159,6 +160,10 @@ __spawni (pid_t *pid, const char *file, } #endif + if ((flags & POSIX_SPAWN_SETSID) != 0 + && __setsid () < 0) + _exit (SPAWN_ERROR); + /* Set the process group ID. */ if ((flags & POSIX_SPAWN_SETPGROUP) != 0 && __setpgid (0, attrp->__pgrp) != 0) diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c index d7f9e83..a10c1aa 100644 --- a/sysdeps/unix/sysv/linux/spawni.c +++ b/sysdeps/unix/sysv/linux/spawni.c @@ -177,6 +177,10 @@ __spawni_child (void *arguments) } #endif + if ((attr->__flags & POSIX_SPAWN_SETSID) != 0 + && __setsid () < 0) + goto fail; + /* Set the process group ID. */ if ((attr->__flags & POSIX_SPAWN_SETPGROUP) != 0 && (ret = __setpgid (0, attr->__pgrp)) != 0) |