當前位置:編程學習大全網 - 網站源碼 - 發送信號為什麽出現User defined signal 1-CSDN論壇

發送信號為什麽出現User defined signal 1-CSDN論壇

您好,很高興為您解答,解決方法如下:

act.sa_sigaction = NULL;這壹行去掉就沒問題了!

#include

#include

#include

#include

void sigusr1_handler(int signo)

{

printf("catch SIGUSR1\n");

sleep(15);

printf("back to main\n");

}

int main(void)

{

struct sigaction act;

act.sa_handler = sigusr1_handler;

act.sa_flags = SA_NODEFER;

sigemptyset(&act.sa_mask);

if(sigaction(SIGUSR1, &act, NULL) == -1)

{

perror("fail to set handler for SIGUSR1");

exit(1);

}

printf("process begin\n");

sleep(15);

printf("done\n");

return 0;

}

如果我的回答沒能幫助您,請繼續追問。轉載,僅供參考。

  • 上一篇:什麽軟件放些不同的資料進去,能快速的查找出來的是什麽軟件啊
  • 下一篇:拼多多砍價全是壹分壹分怎麽辦
  • copyright 2024編程學習大全網