SIGNAL
This commit is contained in:
23
System2/catch_signal/main.c
Normal file
23
System2/catch_signal/main.c
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void sig_usr(int signo)
|
||||
{
|
||||
if (signo == SIGUSR1)
|
||||
printf("received SIGUSR1\n");
|
||||
else if (signo == SIGUSR2)
|
||||
printf("received SIGUSR2\n");
|
||||
else
|
||||
printf("received signal %d\n", signo);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
if (signal(SIGUSR1, sig_usr) == SIG_ERR)
|
||||
printf("can't catch SIGUSR1\n");
|
||||
if (signal(SIGUSR2, sig_usr) == SIG_ERR)
|
||||
printf("can't catch SIGUSR2\n");
|
||||
for (;;)
|
||||
pause();
|
||||
}
|
||||
Reference in New Issue
Block a user