From: Rich Felker Date: Mon, 29 Oct 2012 01:17:45 +0000 (-0400) Subject: system is a cancellation point X-Git-Tag: v0.9.8~70 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=76f28cfce59dfc499252c874f87c34567e6c86c6;p=oweals%2Fmusl.git system is a cancellation point ideally, system would also be cancellable while running the external command, but I cannot find any way to make that work without either leaking zombie processes or introducing behavior that is far outside what the standard specifies. glibc handles cancellation by killing the child process with SIGKILL, but this could be unsafe in that it could leave the data being manipulated by the command in an inconsistent state. --- diff --git a/src/process/system.c b/src/process/system.c index ebe207f5..0cc8b810 100644 --- a/src/process/system.c +++ b/src/process/system.c @@ -13,6 +13,7 @@ weak_alias(dummy_0, __acquire_ptc); weak_alias(dummy_0, __release_ptc); pid_t __vfork(void); +void __testcancel(void); int system(const char *cmd) { @@ -21,6 +22,8 @@ int system(const char *cmd) struct sigaction sa = { .sa_handler = SIG_IGN }, oldint, oldquit; int status = -1, i; + __testcancel(); + if (!cmd) return 1; sigaction(SIGINT, &sa, &oldint);