init commit
This commit is contained in:
Executable
+35
@@ -0,0 +1,35 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user