OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [linux/] [uClibc/] [libc/] [signal/] [sigset.c] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
/* Copyright (C) 1998, 2000 Free Software Foundation, Inc.
2
   This file is part of the GNU C Library.
3
 
4
   The GNU C Library is free software; you can redistribute it and/or
5
   modify it under the terms of the GNU Library General Public License as
6
   published by the Free Software Foundation; either version 2 of the
7
   License, or (at your option) any later version.
8
 
9
   The GNU C Library is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
 
14
   You should have received a copy of the GNU Library General Public
15
   License along with the GNU C Library; see the file COPYING.LIB.  If not,
16
   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
   Boston, MA 02111-1307, USA.  */
18
 
19
#include <errno.h>
20
#define __need_NULL
21
#include <stddef.h>
22
#include <signal.h>
23
 
24
 
25
/* Set the disposition for SIG.  */
26
__sighandler_t sigset (int sig, __sighandler_t disp)
27
{
28
    struct sigaction act, oact;
29
    sigset_t set;
30
 
31
#ifdef SIG_HOLD
32
    /* Handle SIG_HOLD first.  */
33
    if (disp == SIG_HOLD)
34
    {
35
        /* Create an empty signal set.  */
36
        if (__sigemptyset (&set) < 0)
37
            return SIG_ERR;
38
 
39
        /* Add the specified signal.  */
40
        if (__sigaddset (&set, sig) < 0)
41
            return SIG_ERR;
42
 
43
        /* Add the signal set to the current signal mask.  */
44
        if (sigprocmask (SIG_BLOCK, &set, NULL) < 0)
45
            return SIG_ERR;
46
 
47
        return SIG_HOLD;
48
    }
49
#endif  /* SIG_HOLD */
50
 
51
    /* Check signal extents to protect __sigismember.  */
52
    if (disp == SIG_ERR || sig < 1 || sig >= NSIG)
53
    {
54
        __set_errno (EINVAL);
55
        return SIG_ERR;
56
    }
57
 
58
    act.sa_handler = disp;
59
    if (__sigemptyset (&act.sa_mask) < 0)
60
        return SIG_ERR;
61
    act.sa_flags = 0;
62
    if (sigaction (sig, &act, &oact) < 0)
63
        return SIG_ERR;
64
 
65
    /* Create an empty signal set.  */
66
    if (__sigemptyset (&set) < 0)
67
        return SIG_ERR;
68
 
69
    /* Add the specified signal.  */
70
    if (__sigaddset (&set, sig) < 0)
71
        return SIG_ERR;
72
 
73
    /* Remove the signal set from the current signal mask.  */
74
    if (sigprocmask (SIG_UNBLOCK, &set, NULL) < 0)
75
        return SIG_ERR;
76
 
77
    return oact.sa_handler;
78
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.