- root@libin:~/program/C/UNP/research# ./test 6
在另一個端口執行ps -ef而且給父進程發送SIGALRM信號
root 8733 7694 0 15:21 pts/0 00:00:00 ./test 6
root 8734 8733 0 15:21 pts/0 00:00:00 ./test 6
root 8735 8733 0 15:21 pts/0 00:00:00 ./test 6
root 8736 8733 0 15:21 pts/0 00:00:00 ./test 6
root 8737 8733 0 15:21 pts/0 00:00:00 ./test 6
root 8738 8733 0 15:21 pts/0 00:00:00 ./test 6
root 8739 8733 0 15:21 pts/0 00:00:00 ./test 6
root@libin:~# kill -SIGALRM 8733
在執行端口,咱們看到,程序運行50s後,有以下打印:
- catch an alarm signal
- may be interrupted by a signal,let wait again
- i :1 process ID : 8735, parent ID :8733 child ID : 0
- i :0 process ID : 8734, parent ID :8733 child ID : 0
- i :2 process ID : 8736, parent ID :8733 child ID : 0
- i :3 process ID : 8737, parent ID :8733 child ID : 0
- i :4 process ID : 8738, parent ID :8733 child ID : 0
- i :5 process ID : 8739, parent ID :8733 child ID : 0
- i :6 process ID : 8733, parent ID :7694 child ID : 8739