| 1 | |
| 2 | |
| 3 | * Copyright (C) 2023 SUSE
|
| 4 | * Authors: Libor Pechacek <[email protected]>
|
| 5 | * Marcos Paulo de Souza <[email protected]>
|
| 6 |
|
| 7 |
|
| 8 | #include <stdio.h>
|
| 9 | #include <unistd.h>
|
| 10 | #include <sys/syscall.h>
|
| 11 | #include <sys/types.h>
|
| 12 | #include <signal.h>
|
| 13 |
|
| 14 | static int stop;
|
| 15 | static int sig_int;
|
| 16 |
|
| 17 | void hup_handler(int signum)
|
| 18 | {
|
| 19 | stop = 1;
|
| 20 | }
|
| 21 |
|
| 22 | void int_handler(int signum)
|
| 23 | {
|
| 24 | stop = 1;
|
| 25 | sig_int = 1;
|
| 26 | }
|
| 27 |
|
| 28 | int main(int argc, char *argv[])
|
| 29 | {
|
| 30 | long count = 0;
|
| 31 |
|
| 32 | signal(SIGHUP, &hup_handler);
|
| 33 | signal(SIGINT, &int_handler);
|
| 34 |
|
| 35 | while (!stop) {
|
| 36 | (void)syscall(SYS_getpid);
|
| 37 | count++;
|
| 38 | }
|
| 39 |
|
| 40 | if (sig_int)
|
| 41 | printf("%ld iterations done\n", count);
|
| 42 |
|
| 43 | return 0;
|
| 44 | }
|