implement new posix_spawn flag POSIX_SPAWN_SETSID
authorRich Felker <dalias@aerifal.cx>
Sat, 22 Apr 2017 22:39:40 +0000 (18:39 -0400)
committerRich Felker <dalias@aerifal.cx>
Sat, 22 Apr 2017 22:39:40 +0000 (18:39 -0400)
this functionality has been adopted for inclusion in the next issue of
POSIX as the result of Austin Group issue #1044.

based on patch by Daurnimator.

include/spawn.h
src/process/posix_spawn.c

index 29c799ee91c62dbca270eb79709b52f3979c9ee4..f3e9e23c6525bea36b886a6aeb8dc6e7ddd7e260 100644 (file)
@@ -21,6 +21,7 @@ struct sched_param;
 #define POSIX_SPAWN_SETSIGMASK 8
 #define POSIX_SPAWN_SETSCHEDPARAM 16
 #define POSIX_SPAWN_SETSCHEDULER 32
+#define POSIX_SPAWN_SETSID 128
 
 typedef struct {
        int __flags;
index 0bdf71cd8d0437960ea0d7f31a80d0dd151bc651..ea5d29982b8a84b3388800204b64aebdb3c4d52d 100644 (file)
@@ -73,6 +73,10 @@ static int child(void *args_vp)
                __libc_sigaction(i, &sa, 0);
        }
 
+       if (attr->__flags & POSIX_SPAWN_SETSID)
+               if ((ret=__syscall(SYS_setsid)) < 0)
+                       goto fail;
+
        if (attr->__flags & POSIX_SPAWN_SETPGROUP)
                if ((ret=__syscall(SYS_setpgid, 0, attr->__pgrp)))
                        goto fail;