cloudius-systems / osv

OSv, a new operating system for the cloud.
osv.io
Other
4.05k stars 603 forks source link

sigwait() should not return when wrong signal becomes pending #1276

Open wkozaczuk opened 8 months ago

wkozaczuk commented 8 months ago

The current implementation of sigwait():

int sigwait(const sigset_t *set, int *sig)
{
    sched::thread::wait_until([sig] { return *sig = thread_pending_signal; });
    thread_pending_signal = 0;
    return 0;
}

ignores the set argument and returns as soon as any signal is pending for this thread.

According to the Linux manual (https://man7.org/linux/man-pages/man3/sigwait.3.html): "The sigwait() function suspends execution of the calling thread until one of the signals specified in the signal set set becomes pending. "

it should only return if the signal matches bit number set in set.