10dc076565f772bb1953209fb69ea150b494aaa40robbiew/* 20dc076565f772bb1953209fb69ea150b494aaa40robbiew * Copyright (c) 2003, Intel Corporation. All rights reserved. 30dc076565f772bb1953209fb69ea150b494aaa40robbiew * Created by: salwan.searty REMOVE-THIS AT intel DOT com 40dc076565f772bb1953209fb69ea150b494aaa40robbiew * This file is licensed under the GPL license. For the full content 52c28215423293e443469a07ae7011135d058b671Garrett Cooper * of this license, see the COPYING file at the top level of this 60dc076565f772bb1953209fb69ea150b494aaa40robbiew * source tree. 70dc076565f772bb1953209fb69ea150b494aaa40robbiew 80dc076565f772bb1953209fb69ea150b494aaa40robbiew This program tests the assertion that the signal will be added to the 90dc076565f772bb1953209fb69ea150b494aaa40robbiew signal mask before its handler is executed. 100dc076565f772bb1953209fb69ea150b494aaa40robbiew 110dc076565f772bb1953209fb69ea150b494aaa40robbiew*/ 120dc076565f772bb1953209fb69ea150b494aaa40robbiew 130dc076565f772bb1953209fb69ea150b494aaa40robbiew#define _XOPEN_SOURCE 600 140dc076565f772bb1953209fb69ea150b494aaa40robbiew 150dc076565f772bb1953209fb69ea150b494aaa40robbiew#include <signal.h> 160dc076565f772bb1953209fb69ea150b494aaa40robbiew#include <stdio.h> 170dc076565f772bb1953209fb69ea150b494aaa40robbiew#include <stdlib.h> 180dc076565f772bb1953209fb69ea150b494aaa40robbiew#include "posixtest.h" 190dc076565f772bb1953209fb69ea150b494aaa40robbiew 200dc076565f772bb1953209fb69ea150b494aaa40robbiewint signal_blocked = 0; 210dc076565f772bb1953209fb69ea150b494aaa40robbiew 220dc076565f772bb1953209fb69ea150b494aaa40robbiewvoid myhandler(int signo) 230dc076565f772bb1953209fb69ea150b494aaa40robbiew{ 240dc076565f772bb1953209fb69ea150b494aaa40robbiew printf("SIGCHLD called. Inside handler\n"); 250dc076565f772bb1953209fb69ea150b494aaa40robbiew sigset_t mask; 260dc076565f772bb1953209fb69ea150b494aaa40robbiew sigprocmask(SIG_SETMASK, NULL, &mask); 27df3eb16e38c6a163b0a7367c885679eed6140964Garrett Cooper if (sigismember(&mask, SIGCHLD)) { 280dc076565f772bb1953209fb69ea150b494aaa40robbiew signal_blocked = 1; 290dc076565f772bb1953209fb69ea150b494aaa40robbiew } 300dc076565f772bb1953209fb69ea150b494aaa40robbiew} 310dc076565f772bb1953209fb69ea150b494aaa40robbiew 324ca2bbdcd3003f3c8df4e6129e9c7b2bd1514f87Cyril Hrubisint main(void) 330dc076565f772bb1953209fb69ea150b494aaa40robbiew{ 340dc076565f772bb1953209fb69ea150b494aaa40robbiew if (sigset(SIGCHLD, myhandler) == SIG_ERR) { 35354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gao perror("Unexpected error while using sigset()"); 36354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gao return PTS_UNRESOLVED; 37354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gao } 380dc076565f772bb1953209fb69ea150b494aaa40robbiew 390dc076565f772bb1953209fb69ea150b494aaa40robbiew raise(SIGCHLD); 402c28215423293e443469a07ae7011135d058b671Garrett Cooper 410dc076565f772bb1953209fb69ea150b494aaa40robbiew if (signal_blocked != 1) { 42354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gao printf 43354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gao ("Test FAILED: handler was called even though default was expected\n"); 440dc076565f772bb1953209fb69ea150b494aaa40robbiew return PTS_FAIL; 452c28215423293e443469a07ae7011135d058b671Garrett Cooper } 460dc076565f772bb1953209fb69ea150b494aaa40robbiew return PTS_PASS; 47ec6edca7aa42b6affd989ef91b5897f96795e40fChris Dearman} 48