1/* 2 * Copyright (c) 2002-3, Intel Corporation. All rights reserved. 3 * Created by: julie.n.fleischer 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 * Test that the kill() function shall send signal sig to the process 9 * specified by pid. 10 * 1) Set up a signal handler for the signal that says we have caught the 11 * signal. 12 * 2) Call kill on the current process with the signal. 13 * 3) If signal handler was called, test passed. 14 * This test is only performed on one signal. All other signals are 15 * considered to be in the same equivalence class. 16 */ 17 18#define SIGTOTEST SIGABRT 19 20#include <signal.h> 21#include <stdio.h> 22#include <stdlib.h> 23#include <unistd.h> 24#include "posixtest.h" 25 26void handler(int signo) 27{ 28 printf("Caught signal being tested!\n"); 29 printf("Test PASSED\n"); 30 exit(0); 31} 32 33int main() 34{ 35 struct sigaction act; 36 37 act.sa_handler=handler; 38 act.sa_flags=0; 39 if (sigemptyset(&act.sa_mask) == -1) { 40 perror("Error calling sigemptyset\n"); 41 return PTS_UNRESOLVED; 42 } 43 if (sigaction(SIGTOTEST, &act, 0) == -1) { 44 perror("Error calling sigaction\n"); 45 return PTS_UNRESOLVED; 46 } 47 if (kill(getpid(), SIGTOTEST) != 0) { 48 printf("Could not raise signal being tested\n"); 49 return PTS_UNRESOLVED; 50 } 51 52 printf("Should have exited from signal handler\n"); 53 printf("Test FAILED\n"); 54 return PTS_FAIL; 55} 56 57