From 2ddca326beb34d249b23ada39d40fb76c8c4ef70 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Fri, 19 Jun 2020 16:28:43 -0400 Subject: [PATCH] LibC: Add POSIX_SPAWN_SETSIGMASK This isn't in posix yet, but it is implemented on some platforms and it will be in a future version: https://www.austingroupbugs.net/view.php?id=1044 It seems useful, so add it. --- Libraries/LibC/spawn.cpp | 8 +++++++- Libraries/LibC/spawn.h | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Libraries/LibC/spawn.cpp b/Libraries/LibC/spawn.cpp index c8815d9274..026a0fe1df 100644 --- a/Libraries/LibC/spawn.cpp +++ b/Libraries/LibC/spawn.cpp @@ -95,6 +95,12 @@ extern "C" { exit(127); } } + if (flags & POSIX_SPAWN_SETSID) { + if (setsid() < 0) { + perror("posix_spawn setsid"); + exit(127); + } + } // FIXME: POSIX_SPAWN_SETSCHEDULER } @@ -232,7 +238,7 @@ int posix_spawnattr_init(posix_spawnattr_t* attr) int posix_spawnattr_setflags(posix_spawnattr_t* attr, short flags) { - if (flags & ~(POSIX_SPAWN_RESETIDS | POSIX_SPAWN_SETPGROUP | POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETSCHEDULER | POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK)) + if (flags & ~(POSIX_SPAWN_RESETIDS | POSIX_SPAWN_SETPGROUP | POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETSCHEDULER | POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK | POSIX_SPAWN_SETSID)) return EINVAL; attr->flags = flags; diff --git a/Libraries/LibC/spawn.h b/Libraries/LibC/spawn.h index 03bd4c1899..d6d0e03086 100644 --- a/Libraries/LibC/spawn.h +++ b/Libraries/LibC/spawn.h @@ -50,8 +50,12 @@ enum { POSIX_SPAWN_SETSIGDEF = 1 << 4, POSIX_SPAWN_SETSIGMASK = 1 << 5, + + POSIX_SPAWN_SETSID = 1 << 6, }; +#define POSIX_SPAWN_SETSID POSIX_SPAWN_SETSID + struct posix_spawn_file_actions_state; typedef struct { struct posix_spawn_file_actions_state* state;