• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2002-2003, Intel Corporation. All rights reserved.
3  * Created by:  salwan.searty REMOVE-THIS AT intel DOT com
4  * This file is licensed under the GPL license.  For the full content
5  * of this license, see the COPYING file at the top level of this
6  * source tree.
7 
8  This program tests the assertion that sigaltstack() returns 0 upon
9  successful completion.
10 */
11 
12 
13 #include <signal.h>
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include "posixtest.h"
17 
18 #define SIGTOTEST SIGUSR1
19 
20 stack_t alternate_s;
21 
handler()22 void handler()
23 {
24 	printf("Just a dummy handler\n");
25 }
26 
main(void)27 int main(void)
28 {
29 
30 	struct sigaction act;
31 	act.sa_flags = SA_ONSTACK;
32 	act.sa_handler = handler;
33 	sigemptyset(&act.sa_mask);
34 
35 	if (sigaction(SIGUSR1, &act, 0) == -1) {
36 		perror
37 		    ("Unexpected error while attempting to setup test pre-conditions");
38 		return PTS_UNRESOLVED;
39 	}
40 
41 	if ((alternate_s.ss_sp = malloc(SIGSTKSZ)) == NULL) {
42 		perror
43 		    ("Unexpected error while attempting to setup test pre-conditions");
44 		return PTS_UNRESOLVED;
45 	}
46 
47 	alternate_s.ss_flags = 0;
48 	alternate_s.ss_size = SIGSTKSZ;
49 
50 	if (sigaltstack(&alternate_s, NULL) != 0) {
51 		printf("Test FAILED: sigaltstack didn't return 0.\n");
52 		return PTS_FAIL;
53 	}
54 
55 	printf("Test PASSED\n");
56 	return PTS_PASS;
57 }
58