This repository has been archived on 2026-07-28. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
2025-04-13 21:48:15 +03:00

36 lines
482 B
C
Executable File

#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <stdlib.h>
#include <signal.h>
volatile int cnt = 0;
void
f(int n)
{
if (cnt == 5) {
exit(0);
}
printf("%d\n", cnt++);
fflush(stdout);
return;
}
int
main(int argc, char *argv[])
{
sigaction(SIGHUP, &(struct sigaction){.sa_handler = f, .sa_flags = SA_RESTART}, NULL);
printf("%d\n", getpid());
fflush(stdout);
for (;;) {
pause();
}
return 0;
}