废弃的接口:
- int sighold(int sig);
- int sigrelse(int sig);
- int sigignore(int sig);
新接口:
- 不能block SIGKILL or SIGSTOP。
- #include <sys/types.h>
- #include <signal.h>
- int kill(pid_t pid, int sig);
- pid大于0,发送给指定进程;
- pid为0,发送给当前进程所在的进程组;
- pid为-1,发送给所有进程;(当然init进程除外)
- pid小于-1,发送给-pid进程所在的进程组;
- sig为0,执行错误检查;
- 需要有CAP_KILL能力;
union sigval {
int sival_int;
void *sival_ptr;
};
- int sigqueue(pid_t pid, int sig, const union sigval value);
- int raise(int sig);
- unsigned int alarm(unsigned int seconds);
- sigprocmask:在多线程情况下行为未定;
- int pthread_sigmask(int how, const sigset_t *restrict set, sigset_t *restrict oset);
If SIGBUS, SIGFPE, SIGILL, or SIGSEGV are generated while they are blocked, the result is undefined, unless the signal was generated by the kill(2), sigqueue(2), or raise(3).
#include <signal.h>
int sigemptyset(sigset_t *set);
int sigfillset(sigset_t *set);
int sigaddset(sigset_t *set, int signum);
int sigdelset(sigset_t *set, int signum);
int sigismember(const sigset_t *set, int signum);