1
In the following program:
Ctrl+z and ctrl+c both are interrupts.
The code is supposed to handle any interrupt.
Then why does only one of them(ctrl+c) work?
代碼:處理中斷:
#include <signal.h>
#include<stdio.h>
void handler(int sig)
{
printf("Caught SIGINT\n");
exit(0);
}
int main()
{
printf("\nYou can press ctrl+c to test this program\n");
if (signal(SIGINT, handler) == SIG_ERR)
perror("signal error");
pause(); /* wait for the receipt of a signal */
exit(0);
}
由用戶輸入:必須是一箇中斷 輸出必須:夾縫SIGINT
謝謝...我浪費了很多時間在這.. – shibani 2013-03-02 14:10:39