Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wait4 syscall should return pid (tgid) and not the tid to userspace #3886

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Nov 25, 2024

  1. 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.
    sidkshatriya committed Nov 25, 2024
    Configuration menu
    Copy the full SHA
    725d944 View commit details
    Browse the repository at this point in the history