1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 1994 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #pragma ident "%Z%%M% %I% %E% SMI" 28 29 /* 30 * posix signal package 31 */ 32 #include <stdio.h> 33 #include <signal.h> 34 #include <errno.h> 35 36 #define cantmask (sigmask(SIGKILL)|sigmask(SIGSTOP)) 37 38 39 /* 40 * sigemptyset - all known signals 41 */ 42 int 43 sigemptyset(sigset_t *sigp) 44 { 45 if (!sigp) { 46 errno = EINVAL; 47 return (-1); 48 } 49 *sigp = 0; 50 return (0); 51 } 52 53 /* 54 * sigfillset - all known signals 55 */ 56 int 57 sigfillset(sigset_t *sigp) 58 { 59 if (!sigp) { 60 errno = EINVAL; 61 return (-1); 62 } 63 *sigp = sigmask(NSIG - 1) | (sigmask(NSIG - 1) - 1); 64 return (0); 65 } 66 67 /* 68 * add the signal to the set 69 */ 70 int 71 sigaddset(sigset_t *sigp, int signo) 72 { 73 if (!sigp || signo <= 0 || signo >= NSIG) { 74 errno = EINVAL; 75 return (-1); 76 } 77 *sigp |= sigmask(signo); 78 return (0); 79 } 80 81 /* 82 * remove the signal from the set 83 */ 84 int 85 sigdelset(sigset_t *sigp, int signo) 86 { 87 if (!sigp || signo <= 0 || signo >= NSIG) { 88 errno = EINVAL; 89 return (-1); 90 } 91 *sigp &= ~sigmask(signo); 92 return (0); 93 } 94 95 /* 96 * return true if the signal is in the set (return is 0 or 1) 97 */ 98 int 99 sigismember(sigset_t *sigp, int signo) 100 { 101 if (!sigp || signo <= 0 || signo >= NSIG) { 102 errno = EINVAL; 103 return (-1); 104 } 105 return ((*sigp & sigmask(signo)) != 0); 106 } 107