1#include <unistd.h>
2#include <stdio.h>
3#include <signal.h>
4
5static int sigchld_no;
6static int nosig_no;
7static int weird_value;
8
9void
10sigchld_handler (int signo)
11{
12 sigchld_no++;
13 printf (format: "Got sigchld %d.\n", sigchld_no);
14}
15
16int
17call_me (int some_value)
18{
19 int ret_val = 0;
20 int i;
21 for (i = 0; i < some_value; i++)
22 {
23 int result = 0;
24 if (i%2 == 0)
25 result = kill (pid: getpid(), SIGCHLD);
26 else
27 sigchld_no++;
28
29 usleep(useconds: 1000);
30 if (result == 0)
31 ret_val++;
32 }
33 usleep (useconds: 10000);
34 return ret_val;
35}
36
37int
38call_me_nosig (int some_value)
39{
40 int ret_val = 0;
41 int i;
42 for (i = 0; i < some_value; i++)
43 weird_value += i % 4;
44
45 nosig_no += some_value;
46 return some_value;
47}
48
49int
50main ()
51{
52 int ret_val;
53 signal (SIGCHLD, handler: sigchld_handler);
54
55 ret_val = call_me (some_value: 2); // Stop here in main.
56
57 ret_val = call_me_nosig (some_value: 10);
58
59 return 0;
60
61}
62

source code of lldb/test/API/commands/expression/call-restarts/lotta-signals.c