1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2023 SUSE
4 * Authors: Libor Pechacek <lpechacek@suse.cz>
5 *          Marcos Paulo de Souza <mpdesouza@suse.com>
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
14static int stop;
15static int sig_int;
16
17void hup_handler(int signum)
18{
19	stop = 1;
20}
21
22void int_handler(int signum)
23{
24	stop = 1;
25	sig_int = 1;
26}
27
28int 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}
45