File: test1.63.prog.c

package info (click to toggle)
slurm-wlm 22.05.8-4%2Bdeb12u3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 48,492 kB
  • sloc: ansic: 475,246; exp: 69,020; sh: 8,862; javascript: 6,528; python: 6,444; makefile: 4,185; perl: 4,069; pascal: 131
file content (32 lines) | stat: -rw-r--r-- 473 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <signal.h>
#include <stdio.h>
#include <unistd.h>

void ouch(int sig)
{
	static int logged = 0;

	if (logged == 0) {
		logged = 1;
		printf("OUCH! - I got signal %d\n", sig);
		fflush(stdout);
	}
}

int main()
{
	struct sigaction act = {
		.sa_handler = ouch,
		.sa_flags = SA_NODEFER,
	};
	sigemptyset(&act.sa_mask);
	sigaction(SIGINT, &act, 0);

	printf("Hello World!\n");
	fflush(stdout);
	while (1) {
		printf("Sleeping\n");
		fflush(stdout);
		sleep(1);
	}
}