-int test_sigpipe(void)
-{
- sigset_t sigset;
- int result;
-
- result = sigemptyset(&sigset);
- if(result == -1) {
- PERROR("sigemptyset");
- return -1;
- }
- result = sigaddset(&sigset, SIGPIPE);
- if(result == -1) {
- PERROR("sigaddset");
- return -1;
- }
-
- result = sigtimedwait(&sigset, NULL, &(struct timespec){0,0});
- if(result == -1 && errno == EAGAIN) {
- /* no signal received */
- return 0;
- }
- else if(result == -1) {
- PERROR("sigtimedwait");
- return -1;
- }
- else if(result == SIGPIPE) {
- /* received sigpipe */
- return 1;
- }
- else {
- assert(0);
- }
-}
-