3、進程間通信-信號

1、使用sigaction函數 安裝信號(signal函數也可以)

code:

 

2、信號應用sample
     父進程:執行文件拷貝操作,接受SIGUSR1信號,打印拷貝進度
     子進程:每隔一個固定時間(自發SIGALRM信號),向父進程發送SIGUSR1信號。

codes:

結果:

。。。
count:9694673 size:9696669
current over :99.979416%
count:9694899 size:9696669
current over :99.981750%
count:9695107 size:9696669
current over :99.983887%
count:9695300 size:9696669
current over :99.985878%
count:9695498 size:9696669
current over :99.987923%
count:9695712 size:9696669
current over :99.990128%
count:9695898 size:9696669
current over :99.992050%
count:9696072 size:9696669
current over :99.993843%
count:9696298 size:9696669
current over :99.996170%
count:9696539 size:9696669
current over :99.998657%

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章