]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Unix processes / Obtain exit status code
authorWaldemar Zimpel <w.zimpel@dev.utilizer.de>
Sun, 8 Jun 2025 12:20:48 +0000 (14:20 +0200)
committerWaldemar Zimpel <w.zimpel@dev.utilizer.de>
Wed, 11 Jun 2025 07:56:03 +0000 (09:56 +0200)
The actual way for obtaining the exit code
of an exited child process

src/lib/process/waitpid.c

index d98c71c8f23199c28db0c0513c71dbd1615d1f55..51e1d8dcd5e18e79987d2b7da38073de917e1fff 100644 (file)
@@ -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 */
   }