]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
fix: Improve portability of compiler exit status check
authorJoel Rosdahl <joel@rosdahl.net>
Fri, 17 Jul 2026 14:55:34 +0000 (16:55 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 19 Jul 2026 15:18:35 +0000 (17:18 +0200)
WEXITSTATUS(status) should only be used when WIFEXITED(status) is true.
The previous code works on Linux "by accident".

src/ccache/execute.cpp

index c75cbc61e8232b6d3db3ae3087482f016f48a719..34ab6545d0b4889a4250934645244da4c7300593 100644 (file)
@@ -354,11 +354,11 @@ execute(Context& ctx,
     ctx.compiler_pid = 0;
   }
 
-  if (WEXITSTATUS(status) == 0 && WIFSIGNALED(status)) {
+  if (WIFSIGNALED(status)) {
     return -1;
   }
 
-  return WEXITSTATUS(status);
+  return WIFEXITED(status) ? WEXITSTATUS(status) : -1;
 }
 
 void