xref: /linux/tools/perf/tests/workloads/noploop.c (revision 7ae9fb1b7ecbb5d85d07857943f677fd1a559b18)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #include <stdlib.h>
3 #include <signal.h>
4 #include <unistd.h>
5 #include <linux/compiler.h>
6 #include "../tests.h"
7 
8 static volatile sig_atomic_t done;
9 
sighandler(int sig __maybe_unused)10 static void sighandler(int sig __maybe_unused)
11 {
12 	done = 1;
13 }
14 
noploop(int argc,const char ** argv)15 static int noploop(int argc, const char **argv)
16 {
17 	int sec = 1;
18 
19 	if (argc > 0)
20 		sec = atoi(argv[0]);
21 
22 	signal(SIGINT, sighandler);
23 	signal(SIGALRM, sighandler);
24 	alarm(sec);
25 
26 	while (!done)
27 		continue;
28 
29 	return 0;
30 }
31 
32 DEFINE_WORKLOAD(noploop);
33