File: test-66666666.c

package info (click to toggle)
proot 5.4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,012 kB
  • sloc: ansic: 18,627; sh: 1,662; python: 108; asm: 41; makefile: 16; awk: 6
file content (46 lines) | stat: -rw-r--r-- 742 bytes parent folder | download | duplicates (5)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdbool.h>
#include <signal.h>
#include <errno.h>

bool sigtrap_received = false;

void handler(int signo)
{
	if (signo == SIGTRAP)
		sigtrap_received = true;
}

int main()
{
	struct sigaction sa;
	int status;

	sa.sa_flags = 0;
	sa.sa_handler = handler;
	status = sigemptyset(&sa.sa_mask);
	if (status < 0) {
		perror("sigemptyset()");
		exit(EXIT_FAILURE);
	}

	status = sigaction(SIGTRAP, &sa, 0);
	if (status < 0) {
		perror("sigaction(SIGTRAP)");
		exit(EXIT_FAILURE);
	}

	status = raise(SIGTRAP);
	if (status != 0) {
		perror("raise(SIGTRAP)");
		exit(EXIT_FAILURE);
	}

	if (sigtrap_received)
		exit(EXIT_SUCCESS);
	else
		exit(EXIT_FAILURE);
}