Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / tools / testing / selftests / livepatch / test_klp-call_getpid.c
blobce321a2d7308d3f5f280a5e7f4101c26c4879172
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 */
8 #include <stdio.h>
9 #include <unistd.h>
10 #include <sys/syscall.h>
11 #include <sys/types.h>
12 #include <signal.h>
14 static int stop;
15 static int sig_int;
17 void hup_handler(int signum)
19 stop = 1;
22 void int_handler(int signum)
24 stop = 1;
25 sig_int = 1;
28 int main(int argc, char *argv[])
30 long count = 0;
32 signal(SIGHUP, &hup_handler);
33 signal(SIGINT, &int_handler);
35 while (!stop) {
36 (void)syscall(SYS_getpid);
37 count++;
40 if (sig_int)
41 printf("%ld iterations done\n", count);
43 return 0;