summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2020-06-19 16:44:44 -0400
committerAndreas Kling <kling@serenityos.org>2020-06-20 14:43:27 +0200
commited0740d73c40dfdf6f1422629f37a0e9930d80c1 (patch)
tree9ef9f1479e35c245a3226d4f073fa0af566e90d8
parent5208856688b5c02c575e1bcaf3c72238e801eb18 (diff)
downloadserenity-ed0740d73c40dfdf6f1422629f37a0e9930d80c1.zip
LibC: In posix_spawn(), use _exit instead of exit on child error
posix_spawn() tries to present semantics as if no fork() is happening behind the scenes, so running arbitrary atexit handlers of the parent in the child seems like the wrong thing to do.
-rw-r--r--Libraries/LibC/spawn.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/Libraries/LibC/spawn.cpp b/Libraries/LibC/spawn.cpp
index 4c13ccd1e2..c68967fe70 100644
--- a/Libraries/LibC/spawn.cpp
+++ b/Libraries/LibC/spawn.cpp
@@ -56,23 +56,23 @@ extern "C" {
if (flags & POSIX_SPAWN_RESETIDS) {
if (seteuid(getuid()) < 0) {
perror("posix_spawn seteuid");
- exit(127);
+ _exit(127);
}
if (setegid(getgid()) < 0) {
perror("posix_spawn setegid");
- exit(127);
+ _exit(127);
}
}
if (flags & POSIX_SPAWN_SETPGROUP) {
if (setpgid(0, attr->pgroup) < 0) {
perror("posix_spawn setpgid");
- exit(127);
+ _exit(127);
}
}
if (flags & POSIX_SPAWN_SETSCHEDPARAM) {
if (sched_setparam(0, &attr->schedparam) < 0) {
perror("posix_spawn sched_setparam");
- exit(127);
+ _exit(127);
}
}
if (flags & POSIX_SPAWN_SETSIGDEF) {
@@ -85,20 +85,20 @@ extern "C" {
for (int i = 0; i < NSIG; ++i) {
if (sigismember(&sigdefault, i) && sigaction(i, &default_action, nullptr) < 0) {
perror("posix_spawn sigaction");
- exit(127);
+ _exit(127);
}
}
}
if (flags & POSIX_SPAWN_SETSIGMASK) {
if (sigprocmask(SIG_SETMASK, &attr->sigmask, nullptr) < 0) {
perror("posix_spawn sigprocmask");
- exit(127);
+ _exit(127);
}
}
if (flags & POSIX_SPAWN_SETSID) {
if (setsid() < 0) {
perror("posix_spawn setsid");
- exit(127);
+ _exit(127);
}
}
@@ -109,14 +109,14 @@ extern "C" {
for (const auto& action : file_actions->state->actions) {
if (action() < 0) {
perror("posix_spawn file action");
- exit(127);
+ _exit(127);
}
}
}
exec(path, argv, envp);
perror("posix_spawn exec");
- exit(127);
+ _exit(127);
}
int posix_spawn(pid_t* out_pid, const char* path, const posix_spawn_file_actions_t* file_actions, const posix_spawnattr_t* attr, char* const argv[], char* const envp[])