kill :
kill -2 12345
, , , PID ( PID ). (, ignoreInt() PID ), , , - kill .
:
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
static void catchInt(int signum)
{
printf("\nMy sincerest apologies, master (%d)\n", signum);
exit(0);
}
static void catchAlarm(int signum)
{
printf("It great to be alive (%d)\n", signum);
signal(SIGALRM, catchAlarm);
alarm(3);
}
int main(void)
{
pid_t pid = fork();
if (pid < 0)
{
fprintf(stderr, "Fork Failed");
exit(-1);
}
else if (pid == 0)
{
printf("It great to be alive (%d)\n", (int)getpid());
signal(SIGINT, catchInt);
signal(SIGALRM, catchAlarm);
alarm(3);
for ( ;; )
{
printf("I have 42001 children and not one comes to visit\n");
usleep(500000);
}
}
return(0);
}
<sys/types.h>, , , POSIX (, , <unistd.h>). , , , , , , , , . (OTOH, wait(), <sys/wait.h> , , <sys/types.h> .)