diff --git a/libc/src/unistd/waitpid.c b/libc/src/unistd/waitpid.c index a02c2d9..b576f14 100644 --- a/libc/src/unistd/waitpid.c +++ b/libc/src/unistd/waitpid.c @@ -1,6 +1,6 @@ /// @file waitpid.c /// @brief -/// @copyright (c) 2014-2023 This file is distributed under the MIT License. +/// @copyright (c) 2014-2024 This file is distributed under the MIT License. /// See LICENSE.md for details. #include "sys/unistd.h" @@ -18,19 +18,17 @@ pid_t waitpid(pid_t pid, int *status, int options) int __status = 0; do { __inline_syscall3(__res, waitpid, pid, &__status, options); - if (__res < 0) { + if (__res != 0) { break; -} - if (__status == EXIT_ZOMBIE) { - break; -} + } if (options && WNOHANG) { break; -} + } } while (1); + if (status) { *status = __status; -} + } __syscall_return(pid_t, __res); }