tools/nolibc: Implement WTERMSIG()

Message ID 20230427-nolibc-wtermsig-v1-1-6baf4219bb32@kernel.org
State New
Headers
Series tools/nolibc: Implement WTERMSIG() |

Commit Message

Mark Brown April 28, 2023, 3:24 p.m. UTC
  Add an implementation of WTERMSIG() to allow nolibc programs to obtain the
signal that caused the exit of a process, and use it in WIFEXITED() since
the condition being checked there is that no signal was reported.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 tools/include/nolibc/types.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)


---
base-commit: 457391b0380335d5e9a5babdec90ac53928b23b4
change-id: 20230427-nolibc-wtermsig-95c5d064f949

Best regards,
  

Comments

Willy Tarreau May 2, 2023, 6:20 a.m. UTC | #1
Hi Mark,

On Fri, Apr 28, 2023 at 04:24:36PM +0100, Mark Brown wrote:
> Add an implementation of WTERMSIG() to allow nolibc programs to obtain the
> signal that caused the exit of a process, and use it in WIFEXITED() since
> the condition being checked there is that no signal was reported.

Thanks, but Thomas already submitted a similar one that's already queued
for 6.5 in Paul's rcu tree:

  https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git/commit/?h=dev.2023.04.26b&id=8c934d4822c77818d53f5f4c948c3ace6fda1505

At least it further emphasizes the fact that the patch is needed ;-)

Thanks!
Willy
  

Patch

diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h
index fbbc0e68c001..eb0b9f1ffe18 100644
--- a/tools/include/nolibc/types.h
+++ b/tools/include/nolibc/types.h
@@ -79,8 +79,9 @@ 
 #define LINUX_REBOOT_CMD_SW_SUSPEND 0xd000fce2
 
 /* Macros used on waitpid()'s return status */
+#define WTERMSIG(status)    ((status) & 0x7f)
 #define WEXITSTATUS(status) (((status) & 0xff00) >> 8)
-#define WIFEXITED(status)   (((status) & 0x7f) == 0)
+#define WIFEXITED(status)   (WTERMSIG(status) == 0)
 
 /* waitpid() flags */
 #define WNOHANG      1