1255570Strasz/* 2255570Strasz 3255570Strasz * Copyright (c) 2002-2003, Intel Corporation. All rights reserved. 4255570Strasz * Created by: rusty.lynch REMOVE-THIS AT intel DOT com 5255570Strasz * This file is licensed under the GPL license. For the full content 6255570Strasz * of this license, see the COPYING file at the top level of this 7255570Strasz * source tree. 8255570Strasz 9255570Strasz Test case for assertion #12 of the sigaction system call that verifies 10255570Strasz signal-catching functions are executed on the current stack if the 11255570Strasz SA_ONSTACK flag is set in the sigaction.sa_flags parameter to the 12255570Strasz sigaction function call, but a new stack has not be set by sigaltstack(). 13255570Strasz 14255570Strasz NOTE: This test case does not attempt to verify the proper operation 15255570Strasz of sigaltstack. 16255570Strasz*/ 17255570Strasz#define _XOPEN_SOURCE 600 18255570Strasz 19255570Strasz#include <signal.h> 20255570Strasz#include <stdio.h> 21255570Strasz#include <stdlib.h> 22255570Strasz#include "posixtest.h" 23255570Strasz 24255570Straszstack_t current; 25255570Strasz 26255570Straszvoid handler(int signo) 27255570Strasz{ 28255570Strasz stack_t oss; 29255570Strasz 30255570Strasz printf("Caught SIGTSTP\n"); 31255570Strasz 32255570Strasz if (sigaltstack((stack_t *)0, &oss) == -1) { 33255570Strasz perror("Unexpected error while attempting to setup test " 34255570Strasz "pre-conditions"); 35255570Strasz exit(-1); 36255570Strasz } 37255570Strasz 38255570Strasz if (oss.ss_sp != current.ss_sp || oss.ss_size != current.ss_size) { 39255570Strasz printf("Test FAILED\n"); 40255570Strasz exit(-1); 41255570Strasz } 42255570Strasz} 43255570Strasz 44255570Straszint main() 45255570Strasz{ 46255570Strasz struct sigaction act; 47255570Strasz 48255570Strasz act.sa_handler = handler; 49255570Strasz act.sa_flags = SA_ONSTACK; 50255570Strasz sigemptyset(&act.sa_mask); 51255570Strasz if (sigaction(SIGTSTP, &act, 0) == -1) { 52255570Strasz perror("Unexpected error while attempting to setup test " 53255570Strasz "pre-conditions"); 54255570Strasz return PTS_UNRESOLVED; 55255570Strasz } 56255570Strasz 57255570Strasz if (sigaltstack((stack_t *)0, ¤t) == -1) { 58255570Strasz perror("Unexpected error while attempting to setup test " 59255570Strasz "pre-conditions"); 60255570Strasz return PTS_UNRESOLVED; 61255570Strasz } 62255570Strasz 63255570Strasz if (raise(SIGTSTP) == -1) { 64255570Strasz perror("Unexpected error while attempting to setup test " 65255570Strasz "pre-conditions"); 66255570Strasz return PTS_UNRESOLVED; 67255570Strasz } 68255570Strasz 69255570Strasz printf("Test PASSED\n"); 70255570Strasz return PTS_PASS; 71255570Strasz} 72255570Strasz