Write more tests for signal handling

There's now a much stronger level of assurance that signaling on Windows
will be atomic, low-latency, low tail latency, and shall never deadlock.
This commit is contained in:
Justine Tunney 2024-09-21 05:24:56 -07:00
parent 0e59afb403
commit dd8c4dbd7d
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
19 changed files with 407 additions and 75 deletions

View file

@ -89,6 +89,7 @@ struct PosixThread {
locale_t pt_locale;
jmp_buf pt_exiter;
pthread_attr_t pt_attr;
atomic_bool pt_intoff;
};
typedef void (*atfork_f)(void);

View file

@ -43,7 +43,9 @@ errno_t pthread_kill(pthread_t thread, int sig) {
int err = 0;
struct PosixThread *pt;
pt = (struct PosixThread *)thread;
if (!(1 <= sig && sig <= 64)) {
if (!thread) {
err = EFAULT;
} else if (!(1 <= sig && sig <= 64)) {
err = EINVAL;
} else if (thread == __get_tls()->tib_pthread) {
err = raise(sig); // XNU will EDEADLK it otherwise
@ -62,9 +64,8 @@ errno_t pthread_kill(pthread_t thread, int sig) {
errno = e;
}
}
if (err == ESRCH) {
if (err == ESRCH)
err = 0; // we already reported this
}
}
STRACE("pthread_kill(%d, %G) → %s", _pthread_tid(pt), sig,
DescribeErrno(err));