#include <pthread.h>
#include <signal.h>
int pthread_kill(pthread_t thread, int signo);
int pthread_sigmask(int how, const sigset_t *newmask,
sigset_t *oldmask);
int sigwait(const sigset_t *set, int *sig);
1.2. 설명
이 함수는 현재 쓰레드에 시그널newmask와 how 를 이용해서 시그널
마스크를 만든다. how는 SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK중
하나를 선택할 수 있다. SIG_BLOCK는 현재 설정된 시그널 마스크에
newmask를 추가하며 SIG_UNBLOCK는 현재 설정된 시그널
마스크에서 newmask를 제거하고 SIG_SETMASK는 newmask로 현재
시그널 마스크를 설정한다
pthread_kill()은 시그널번호signo를 가지는
시그널을 스레드 식별번호thread를 가지는
쓰레드에 전달한다.
sigwait()는 시그널 셋set에 지정된 시그널이
전달될 때까지 해당영역에서 대기한다. 만약 시그널을 받게 되면
받은 시그널 번호를 sig에 복사하고 리턴한다.
set에 명시된 시그널들은 반드시 봉쇄로 지정되어야
한다. 그래야만 sigwait()에 의해서 검출되고 리턴된다. 만약
해당 시그널에 대해서 시그널 핸들러가 지정되어 있다면 함수는
호출되지 않게 된다.
1장. pthread_kill(3)
쓰레드 시그널 관련 함수들
1.1. 사용법
1.2. 설명
이 함수는 현재 쓰레드에 시그널newmask와 how 를 이용해서 시그널 마스크를 만든다. how는 SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK중 하나를 선택할 수 있다. SIG_BLOCK는 현재 설정된 시그널 마스크에 newmask를 추가하며 SIG_UNBLOCK는 현재 설정된 시그널 마스크에서 newmask를 제거하고 SIG_SETMASK는 newmask로 현재 시그널 마스크를 설정한다
pthread_kill()은 시그널번호signo를 가지는 시그널을 스레드 식별번호thread를 가지는 쓰레드에 전달한다.
sigwait()는 시그널 셋set에 지정된 시그널이 전달될 때까지 해당영역에서 대기한다. 만약 시그널을 받게 되면 받은 시그널 번호를 sig에 복사하고 리턴한다. set에 명시된 시그널들은 반드시 봉쇄로 지정되어야 한다. 그래야만 sigwait()에 의해서 검출되고 리턴된다. 만약 해당 시그널에 대해서 시그널 핸들러가 지정되어 있다면 함수는 호출되지 않게 된다.
1.3. 반환값
성공하면 0을, 실패하면 0이 아닌 값을 리턴한다.
1.4. 에러
th식별자를 가진 쓰레드가 존재하지 않는다.
th식별자를 가진 쓰레드가 이미 detach상태에 있다.
1.5. 예제
1.6. 참고문헌
쓰레드와 시그널
Pthread API 레퍼런스
Recent Posts
Archive Posts
Tags