blob: d33c68c3bf6251b47fccdeb40ba5557ba39b1d77 (
plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
/*
* Copyright (c) 2003, Intel Corporation. All rights reserved.
* Copyright (c) 2013, Cyril Hrubis <chrubis@suse.cz>
*
* Created by: salwan.searty REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
*
* Steps:
* 1. Set up a handler for signal SIGABRT, such that it is called if
* signal is ever raised.
* 2. Call sighold on that SIGABRT.
* 3. Raise a SIGABRT and verify that the signal handler was not called.
* Otherwise, the test exits with unresolved results.
* 4. Call sigrelse on SIGABRT.
* 5. Verify that the handler gets called this time.
*/
#include <signal.h>
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include "posixtest.h"
static int handler_called;
static void handler(int signo)
{
handler_called = 1;
}
int main(void)
{
struct sigaction act;
struct timespec signal_wait_ts = {0, 100000000};
act.sa_handler = handler;
act.sa_flags = 0;
sigemptyset(&act.sa_mask);
if (sigaction(SIGABRT, &act, 0) == -1) {
perror("Failed to set signal handler.");
return PTS_UNRESOLVED;
}
sighold(SIGABRT);
if (raise(SIGABRT) == -1) {
perror("Failed to raise SIGABRT.");
return PTS_UNRESOLVED;
}
if (handler_called) {
printf("UNRESOLVED. possible problem in sigrelse\n");
return PTS_UNRESOLVED;
}
if (sigrelse(SIGABRT) == -1) {
printf("UNRESOLVED. possible problem in sigrelse\n");
return PTS_UNRESOLVED;
}
nanosleep(&signal_wait_ts, NULL);
if (handler_called) {
printf("Test PASSED: SIGABRT removed from signal mask\n");
return PTS_PASS;
}
printf("Test FAILED\n");
return PTS_FAIL;
}
|