Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wait4 syscall should return pid (tgid) and not the tid to userspace
This is what the kernel does. Fix emulation to do the same. In glibc waitpid() i.e. __waitpid() is implemented in terms of wait4() i.e. __wait4() which is a thin wrapper over the wait4 syscall. wait4 syscall returns the pid (tgid in kernel parlance) and not the thread id (tid). tid and pid will, of course, often be different in multithreaded situations. See also `man wait4` and `man waitpid`. This should fix the unexpected behavior of waitpid() in programs in which the return pid_t is checked against an expected value or used for further bookkeeping/comparisons. In such programs, the failure can be rare because due to thread sequencing, sometimes the tid happens to be numerically the pid that is expected and sometimes it is not.
- Loading branch information