From: Waldemar Zimpel Date: Sun, 8 Jun 2025 12:20:48 +0000 (+0200) Subject: Unix processes / Obtain exit status code X-Git-Tag: tor-0.4.8.17~4^2^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3c1ff4a7ef296bb13dd3bdd75483c83ea8b29635;p=thirdparty%2Ftor.git Unix processes / Obtain exit status code The actual way for obtaining the exit code of an exited child process --- diff --git a/src/lib/process/waitpid.c b/src/lib/process/waitpid.c index d98c71c8f2..51e1d8dcd5 100644 --- a/src/lib/process/waitpid.c +++ b/src/lib/process/waitpid.c @@ -1,6 +1,6 @@ /* Copyright (c) 2003-2004, Roger Dingledine * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. - * Copyright (c) 2007-2021, The Tor Project, Inc. */ + * Copyright (c) 2007-2025, The Tor Project, Inc. */ /* See LICENSE for licensing information */ /** @@ -146,6 +146,7 @@ notify_pending_waitpid_callbacks(void) int status = 0; while ((child = waitpid(-1, &status, WNOHANG)) > 0) { + status = WIFEXITED(status) ? WEXITSTATUS(status) : -1; notify_waitpid_callback_by_pid(child, status); status = 0; /* should be needless */ }