mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-02 17:28:30 +00:00
Implement raise() with getcontext() / setcontext()
This commit is contained in:
parent
dd83db9567
commit
736fdb757a
12 changed files with 73 additions and 97 deletions
|
@ -23,6 +23,7 @@
|
|||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/runtime/syslib.internal.h"
|
||||
#include "libc/sysv/consts/sicode.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
/**
|
||||
* Sends signal to self.
|
||||
|
@ -35,6 +36,7 @@
|
|||
*
|
||||
* @param sig can be SIGALRM, SIGINT, SIGTERM, SIGKILL, etc.
|
||||
* @return 0 on success, or nonzero on failure
|
||||
* @raise EINVAL if `sig` is invalid
|
||||
* @asyncsignalsafe
|
||||
*/
|
||||
int raise(int sig) {
|
||||
|
@ -42,8 +44,12 @@ int raise(int sig) {
|
|||
if (IsXnuSilicon()) {
|
||||
rc = __syslib->__raise(sig);
|
||||
} else if (IsWindows()) {
|
||||
__sig_raise(sig, SI_TKILL);
|
||||
rc = 0;
|
||||
if (0 <= sig && sig <= 64) {
|
||||
__sig_raise(sig, SI_TKILL);
|
||||
rc = 0;
|
||||
} else {
|
||||
rc = einval();
|
||||
}
|
||||
} else {
|
||||
rc = sys_tkill(gettid(), sig, 0);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue