Linux????????????
???????????? ???????[ 2015/1/22 13:57:33 ] ????????Linux ??????
????2.2 sigwait
???????????????sigwait()??????????????????????
????#include <signal.h>
????int sigwait(const sigset_t *restrict sigset?? int *restrict signop);
????????sigset????????????????signop??????????????????????????ú???????????????????????е??κ??????????????ú????????????????????δ???????????(????????????signal/sigaction???????????????)?????????????????ú?????г???????0?????????????????????signop????????????????????????(errno)????????????EINVAL(????????Ч?????)????????????EINTR????
????????????δ????????????????δ????????????δ???????????????????????????????sigwait()?????????δ????????ú??????????????????????ж??????е???????δ???????????Щ??????????????δ???塣?????????sigwait()?????????????????????????δ??????
????????????????????е???????sigwait()????????????????????????????μ???????????????????sigwait()???????????????????????sigwait()????????????????????????sigwait()??????“????-???-????”???????????????????????
????????????????????sigwait()???????????Щ????????????????????????У????ó??????????sigprocmask()????????????е??????????Щ???????????sigwait()??????????δ??????????????????????????????????????????У????????(???????????)??????????????????е?????????????????????????????????????????????????????????pthread_sigmask()??????Щ???(????????????????)??????????????????(sigwait????????????????????)??
??????????????sigwait()???????????????(??????????)?????sigwait()?з??????????????(???sigaction????????????)???????????sigwait()?????е??????????????????????????????????????????????????sigwait????(???????????)????????????????????????????????????????
???????sigwait()??sigwaitinfo()???????????????????????????sigwait()????????0??????????????????????errno????sigwaitinfo()??????????????????siginfo_t??(???????)????????????errno??????-1?????? ???????????????????????????????????????ж?sigwaitinfo()?????errno???????EINTR??
??????SIGKILL (???????)?? SIGSTOP(???????)?????????????????
???????sigwait()????????????е????????????????????????????????????????????????????????????ж??????????????????????????????У??????????????????????????????????κκ?????????????????????????????????????????????Щ??????????????????????????????????δ????ж????????С?????????????????????????????????
?????????????????????????????????????????
???????????????£?
????1) ??????????????????????????????????????
????2) ????????????????????????????????????????????? sigwait()???????
????3) ??????????????????
????????????????????????????????У?????????????????????
?????????????????????????????(??SIGUSR1/ SIGUSR2???????)??????????????????????У?????????sigwait????????????????????????????????????????????????????????????????3???????????????(??SIGSEGV)???????????????????? signal()??sigaction()???????????????з?????????????????????????????ó????У?????????????????????????????????????????
???????sigwait()??????????????????????????????????????????????????????????????????????????????????????????????????
????2.3 pthread_kill
??????ó???????pthread_kill()???????????????????????????(???????)??
????#include <signal.h>
????int pthread_kill(pthread_t thread?? int signo);
?????ú?????signo???????????????????????????thread?????ú?????г???????0?????????????(errno)??????????????????????ESRCH(???????????)??EINVAL(????????Ч?????)????????????EINTR????
??????signo??????0(?????)????pthread_kill()????д????鰱????ESRCH???????????????????????????????????ж????????????????????kill(pid?? 0)???????ж??????????????(????-1??????errno?ESRCH)?????磺
1 int ThreadKill(pthread_t tThrdId?? int dwSigNo)
2 {
3 int dwRet = pthread_kill(tThrdId?? dwSigNo);
4 if(dwRet == ESRCH)
5 printf("Thread %x is non-existent(Never Created or Already Quit)!
"??
6 (unsigned int)tThrdId);
7 else if(dwRet == EINVAL)
8 printf("Signal %d is invalid!
"?? dwSigNo);
9 else
10 printf("Thread %x is alive!
"?? (unsigned int)tThrdId);
11
12 return dwRet;
13 }
|
???????????????????????????????y????????????????????????????????????????????????????????????????????kill()?????????????????????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11