/* * Copyright (c) 2003, Intel Corporation. All rights reserved. * 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. Assumption: The test assumes that this program is run under normal conditions, and not when the processor and other resources are too stressed. Steps: 1. Fork() a child process. In the child, add SIGUSR1 to the process's signal mask. This is its original signal mask. Now suspend the child, passing sigsuspend another signal mask. One that doesn't contain SIGUSR1, but contains SIGUSR2. 2. From the parent, send the child a SIGUSR1 signal so that the child returns from suspension. 3. Once the sigsuspend returns, have the child probe the signal mask using the is_changed() function which basically verifies that the signal mask is restored to what it was originally before the call to sigsuspend. I.e. SIGUSR1 in the mask and SIGUSR2 not in the mask. Have the child return to the parent process with: - a return value of 1 if the original signal mask was not restored, or - a return value of 0 if the original signal mask was successfully restored. 4. Finally from the parent, return a PTS_PASS if recieved the return value of the child was not a 1. */ #include #include #include #include #include #include #include "posixtest.h" #define NUMSIGNALS 26 void handler(int signo) { printf("Now inside signal handler\n"); } int is_changed(sigset_t set, int sig) { int i; int siglist[] = {SIGABRT, SIGALRM, SIGBUS, SIGCHLD, SIGCONT, SIGFPE, SIGHUP, SIGILL, SIGINT, SIGPIPE, SIGQUIT, SIGSEGV, SIGTERM, SIGTSTP, SIGTTIN, SIGTTOU, SIGUSR1, SIGUSR2, SIGPOLL, SIGPROF, SIGSYS, SIGTRAP, SIGURG, SIGVTALRM, SIGXCPU, SIGXFSZ }; if (sigismember(&set, sig) != 1) { return 1; } for (i=0; i