* [PATCH] tools/nolibc: handle NULL wstatus arugment to waitpid()
@ 2025-09-26 14:26 Thomas Weißschuh
2025-09-27 9:45 ` Willy Tarreau
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Weißschuh @ 2025-09-26 14:26 UTC (permalink / raw)
To: Willy Tarreau, Thomas Weißschuh; +Cc: linux-kernel, Thomas Weißschuh
wstatus is allowed to be NULL. Avoid a segmentation fault in this case.
Fixes: 0c89abf5ab3f ("tools/nolibc: implement waitpid() in terms of waitid()")
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
tools/include/nolibc/sys/wait.h | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/tools/include/nolibc/sys/wait.h b/tools/include/nolibc/sys/wait.h
index 4e66e1f7a03e4585c91ec4ea68333b910600239a..9d9319ba92cbd31ee00afa85a2105d7bb00751b8 100644
--- a/tools/include/nolibc/sys/wait.h
+++ b/tools/include/nolibc/sys/wait.h
@@ -65,23 +65,29 @@ pid_t waitpid(pid_t pid, int *status, int options)
switch (info.si_code) {
case 0:
- *status = 0;
+ if (status)
+ *status = 0;
break;
case CLD_EXITED:
- *status = (info.si_status & 0xff) << 8;
+ if (status)
+ *status = (info.si_status & 0xff) << 8;
break;
case CLD_KILLED:
- *status = info.si_status & 0x7f;
+ if (status)
+ *status = info.si_status & 0x7f;
break;
case CLD_DUMPED:
- *status = (info.si_status & 0x7f) | 0x80;
+ if (status)
+ *status = (info.si_status & 0x7f) | 0x80;
break;
case CLD_STOPPED:
case CLD_TRAPPED:
- *status = (info.si_status << 8) + 0x7f;
+ if (status)
+ *status = (info.si_status << 8) + 0x7f;
break;
case CLD_CONTINUED:
- *status = 0xffff;
+ if (status)
+ *status = 0xffff;
break;
default:
return -1;
---
base-commit: 2d965c1ae4135ed6f505661458f6dabd39488dac
change-id: 20250926-nolibc-waitpid-nullable-d030eb3693d7
Best regards,
--
Thomas Weißschuh <thomas.weissschuh@linutronix.de>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] tools/nolibc: handle NULL wstatus arugment to waitpid()
2025-09-26 14:26 [PATCH] tools/nolibc: handle NULL wstatus arugment to waitpid() Thomas Weißschuh
@ 2025-09-27 9:45 ` Willy Tarreau
0 siblings, 0 replies; 2+ messages in thread
From: Willy Tarreau @ 2025-09-27 9:45 UTC (permalink / raw)
To: Thomas Weißschuh; +Cc: Thomas Weißschuh, linux-kernel
On Fri, Sep 26, 2025 at 04:26:58PM +0200, Thomas Weißschuh wrote:
> wstatus is allowed to be NULL. Avoid a segmentation fault in this case.
>
> Fixes: 0c89abf5ab3f ("tools/nolibc: implement waitpid() in terms of waitid()")
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Good catch Thomas!
Acked-by: Willy Tarreau <w@1wt.eu>
Willy
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-09-27 9:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-26 14:26 [PATCH] tools/nolibc: handle NULL wstatus arugment to waitpid() Thomas Weißschuh
2025-09-27 9:45 ` Willy Tarreau
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox