mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
tools/nolibc: handle NULL wstatus argument to waitpid()
wstatus is allowed to be NULL. Avoid a segmentation fault in this case.
Fixes: 0c89abf5ab ("tools/nolibc: implement waitpid() in terms of waitid()")
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
This commit is contained in:
committed by
Thomas Weißschuh
parent
3a86608788
commit
812f223fe9
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user