From: Rich Felker Date: Wed, 29 Aug 2018 00:39:26 +0000 (-0400) Subject: fix return value of system on failure to spawn child process X-Git-Tag: v1.1.20~14 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=1d297a2821f8c5c5bc13b0bad88c966603ef46dc;p=oweals%2Fmusl.git fix return value of system on failure to spawn child process the value 0x7f00 (as if by _exit(127)) is specified only for the case where the child is created but then fails to exec the shell, since traditional fork+exec implementations do not admit reporting an error via errno in this case without additional machinery. it's unclear whether an implementation not subject to this failure mode needs to emulate it; one could read the standard as requiring that. if so, additional code will need to be added to map posix_spawn errors into the form system is expected to return. but for now, returning -1 to indicate an error is significantly better behavior than always reporting failures as if the shell failed to exec after fork. --- diff --git a/src/process/system.c b/src/process/system.c index 8cbdda06..9135b815 100644 --- a/src/process/system.c +++ b/src/process/system.c @@ -14,7 +14,7 @@ int system(const char *cmd) pid_t pid; sigset_t old, reset; struct sigaction sa = { .sa_handler = SIG_IGN }, oldint, oldquit; - int status = 0x7f00, ret; + int status = -1, ret; posix_spawnattr_t attr; pthread_testcancel();