1.属性
①每个线程都有自己的信号屏蔽字
②但是信号的处理是进程中所有进程共享的
③进程中的信号是递送到单个线程的,只体现在该进程的pedding上,(谁来响应 就要看从kernel态到usr态 调度的是哪个线程)。首先先拿线程的mask和进程的pedding按位与,在那线程mask和线程pedding按位与
④一个线程给一个线程发信号,体现在该线程的pedding上
2.函数
pthread_sigmask
NAME
pthread_sigmask - examine and change mask of blocked signals
SYNOPSIS
#include <signal.h>
int pthread_sigmask(int how, const sigset_t *set, sigset_t *oldset);
Compile and link with -pthread.
DESCRIPTION
The pthread_sigmask() function is just like sigprocmask(2)
**sigwait **
NAME
sigwait - wait for a signal
SYNOPSIS
#include <signal.h>
int sigwait(const sigset_t *set, int *sig);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
sigwait(): _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE
DESCRIPTION
The sigwait() function suspends execution of the calling thread
until one of the signals specified in the signal set set becomes
pending
pthread_kill
NAME
pthread_kill - send a signal to a thread
SYNOPSIS
#include <signal.h>
int pthread_kill(pthread_t thread, int sig);
Compile and link with -pthread.
DESCRIPTION
The pthread_kill() function sends the signal sig to thread,
a thread in the same process as the caller.
3.线程与fork
当线程调用fork时,就为子进程创建了整个地址空间的副本。
子进程通过继承整个地址空间的副本,还从父进程那里继承了每个互斥量,读写锁和条件变量的状态。如果父进程包含一个以上的线程,子进程在fork返回以后,如果不马上exec的话,就需要清理锁的状态。
未完待续