mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-29 00:32:29 +00:00
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:
parent
0e59afb403
commit
dd8c4dbd7d
19 changed files with 407 additions and 75 deletions
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue