• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 
3  * Copyright (c) 2002-2003, Intel Corporation. All rights reserved.
4  * Created by:  rusty.lynch REMOVE-THIS AT intel DOT com
5  * This file is licensed under the GPL license.  For the full content
6  * of this license, see the COPYING file at the top level of this
7  * source tree.
8 
9   Test case for assertion #12 of the sigaction system call that verifies
10   signal-catching functions are executed on the current stack if the
11   SA_ONSTACK flag is set in the sigaction.sa_flags parameter to the
12   sigaction function call, but a new stack has not be set by sigaltstack().
13 
14   NOTE: This test case does not attempt to verify the proper operation
15         of sigaltstack.
16 */
17 
18 #include <signal.h>
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include "posixtest.h"
22 
23 stack_t current;
24 
handler(int signo)25 void handler(int signo)
26 {
27 	stack_t oss;
28 
29 	printf("Caught SIGCONT\n");
30 
31 	if (sigaltstack(NULL, &oss) == -1) {
32 		perror("Unexpected error while attempting to setup test "
33 		       "pre-conditions");
34 		exit(-1);
35 	}
36 
37 	if (oss.ss_sp != current.ss_sp || oss.ss_size != current.ss_size) {
38 		printf("Test FAILED\n");
39 		exit(-1);
40 	}
41 }
42 
main(void)43 int main(void)
44 {
45 	struct sigaction act;
46 
47 	act.sa_handler = handler;
48 	act.sa_flags = SA_ONSTACK;
49 	sigemptyset(&act.sa_mask);
50 	if (sigaction(SIGCONT, &act, 0) == -1) {
51 		perror("Unexpected error while attempting to setup test "
52 		       "pre-conditions");
53 		return PTS_UNRESOLVED;
54 	}
55 
56 	if (sigaltstack(NULL, &current) == -1) {
57 		perror("Unexpected error while attempting to setup test "
58 		       "pre-conditions");
59 		return PTS_UNRESOLVED;
60 	}
61 
62 	if (raise(SIGCONT) == -1) {
63 		perror("Unexpected error while attempting to setup test "
64 		       "pre-conditions");
65 		return PTS_UNRESOLVED;
66 	}
67 
68 	printf("Test PASSED\n");
69 	return PTS_PASS;
70 }
71