signals.c
author viric@llimona
Fri, 13 Apr 2007 20:50:31 +0200
changeset 125 b60f173b1489
parent 102 27b0f0e44de8
child 138 00461b7bdf4b
permissions -rw-r--r--
Copyright for list.c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
102
27b0f0e44de8 Added copyright headers to the new files. I always forget that.
viric@llimona
parents: 95
diff changeset
     1
/*
27b0f0e44de8 Added copyright headers to the new files. I always forget that.
viric@llimona
parents: 95
diff changeset
     2
    Task Spooler - a task queue system for the unix user
27b0f0e44de8 Added copyright headers to the new files. I always forget that.
viric@llimona
parents: 95
diff changeset
     3
    Copyright (C) 2007  LluĂ­s Batlle i Rossell
27b0f0e44de8 Added copyright headers to the new files. I always forget that.
viric@llimona
parents: 95
diff changeset
     4
27b0f0e44de8 Added copyright headers to the new files. I always forget that.
viric@llimona
parents: 95
diff changeset
     5
    Please find the license in the provided COPYING file.
27b0f0e44de8 Added copyright headers to the new files. I always forget that.
viric@llimona
parents: 95
diff changeset
     6
*/
95
d31aaee661d1 Protection against SIGPIPE. Block it.
viric@llimona
parents:
diff changeset
     7
#include <signal.h>
d31aaee661d1 Protection against SIGPIPE. Block it.
viric@llimona
parents:
diff changeset
     8
#include <stdlib.h> /* for NULL */
d31aaee661d1 Protection against SIGPIPE. Block it.
viric@llimona
parents:
diff changeset
     9
d31aaee661d1 Protection against SIGPIPE. Block it.
viric@llimona
parents:
diff changeset
    10
/* Some externs refer to this variable */
d31aaee661d1 Protection against SIGPIPE. Block it.
viric@llimona
parents:
diff changeset
    11
static sigset_t normal_sigmask;
d31aaee661d1 Protection against SIGPIPE. Block it.
viric@llimona
parents:
diff changeset
    12
d31aaee661d1 Protection against SIGPIPE. Block it.
viric@llimona
parents:
diff changeset
    13
void ignore_sigpipe()
d31aaee661d1 Protection against SIGPIPE. Block it.
viric@llimona
parents:
diff changeset
    14
{
d31aaee661d1 Protection against SIGPIPE. Block it.
viric@llimona
parents:
diff changeset
    15
    sigset_t set;
d31aaee661d1 Protection against SIGPIPE. Block it.
viric@llimona
parents:
diff changeset
    16
d31aaee661d1 Protection against SIGPIPE. Block it.
viric@llimona
parents:
diff changeset
    17
    sigemptyset(&set);
d31aaee661d1 Protection against SIGPIPE. Block it.
viric@llimona
parents:
diff changeset
    18
    sigaddset(&set, SIGPIPE);
d31aaee661d1 Protection against SIGPIPE. Block it.
viric@llimona
parents:
diff changeset
    19
    sigprocmask(SIG_BLOCK, &set, &normal_sigmask);
d31aaee661d1 Protection against SIGPIPE. Block it.
viric@llimona
parents:
diff changeset
    20
}
d31aaee661d1 Protection against SIGPIPE. Block it.
viric@llimona
parents:
diff changeset
    21
d31aaee661d1 Protection against SIGPIPE. Block it.
viric@llimona
parents:
diff changeset
    22
void restore_sigmask()
d31aaee661d1 Protection against SIGPIPE. Block it.
viric@llimona
parents:
diff changeset
    23
{
d31aaee661d1 Protection against SIGPIPE. Block it.
viric@llimona
parents:
diff changeset
    24
    sigprocmask(SIG_SETMASK, &normal_sigmask, NULL);
d31aaee661d1 Protection against SIGPIPE. Block it.
viric@llimona
parents:
diff changeset
    25
}
d31aaee661d1 Protection against SIGPIPE. Block it.
viric@llimona
parents:
diff changeset
    26