提交 370f78f2 编写于 作者: R Rich Felker

fix raise semantics with threads.

上级 91f7db26
#include <signal.h>
#include <errno.h>
#include "syscall.h"
int raise(int sig)
{
return __syscall_kill(__syscall_getpid(), sig);
int pid, tid, ret;
/* Getting the pid/tid pair is not atomic, and could give wrong
* result if a fork occurs in a signal handler between the two
* syscalls. Use the tgkill syscall's ESRCH semantics to detect
* this condition and retry. */
do {
tid = syscall0(__NR_gettid);
pid = syscall0(__NR_getpid);
ret = syscall3(__NR_tgkill, pid, tid, sig);
} while (ret<0 && errno == ESRCH);
return ret;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册