1/*
2 * Copyright (c) 1982, 1986, 1989, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.
--- 21 unchanged lines hidden (view full) ---
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)kern_sig.c 8.7 (Berkeley) 4/18/94
35 */
36
37#include <sys/cdefs.h>
38__FBSDID("$FreeBSD: head/sys/kern/kern_sig.c 130344 2004-06-11 11:16:26Z phk $");
39
40#include "opt_compat.h"
41#include "opt_ktrace.h"
42
43#include <sys/param.h>
44#include <sys/systm.h>
45#include <sys/signalvar.h>
46#include <sys/vnode.h>
--- 183 unchanged lines hidden (view full) ---
230}
231
232int
233sigonstack(size_t sp)
234{
235 struct thread *td = curthread;
236
237 return ((td->td_pflags & TDP_ALTSTACK) ?
238#if defined(COMPAT_43)
239 ((td->td_sigstk.ss_size == 0) ?
240 (td->td_sigstk.ss_flags & SS_ONSTACK) :
241 ((sp - (size_t)td->td_sigstk.ss_sp) < td->td_sigstk.ss_size))
242#else
243 ((sp - (size_t)td->td_sigstk.ss_sp) < td->td_sigstk.ss_size)
244#endif
245 : 0);
246}
--- 95 unchanged lines hidden (view full) ---
342 if (act->sa_flags & SA_RESETHAND)
343 SIGADDSET(ps->ps_sigreset, sig);
344 else
345 SIGDELSET(ps->ps_sigreset, sig);
346 if (act->sa_flags & SA_NODEFER)
347 SIGADDSET(ps->ps_signodefer, sig);
348 else
349 SIGDELSET(ps->ps_signodefer, sig);
350 if (sig == SIGCHLD) {
351 if (act->sa_flags & SA_NOCLDSTOP)
352 ps->ps_flag |= PS_NOCLDSTOP;
353 else
354 ps->ps_flag &= ~PS_NOCLDSTOP;
355 if (act->sa_flags & SA_NOCLDWAIT) {
356 /*
357 * Paranoia: since SA_NOCLDWAIT is implemented
--- 631 unchanged lines hidden (view full) ---
989 siglist = p->p_siglist;
990 SIGSETOR(siglist, td->td_siglist);
991 PROC_UNLOCK(p);
992 SIG2OSIG(siglist, td->td_retval[0]);
993 return (0);
994}
995#endif /* COMPAT_43 */
996
997#if defined(COMPAT_43)
998/*
999 * Generalized interface signal handler, 4.3-compatible.
1000 */
1001#ifndef _SYS_SYSPROTO_H_
1002struct osigvec_args {
1003 int signum;
1004 struct sigvec *nsv;
1005 struct sigvec *osv;
--- 20 unchanged lines hidden (view full) ---
1026 if (nsap) {
1027 error = copyin(uap->nsv, &vec, sizeof(vec));
1028 if (error)
1029 return (error);
1030 nsap->sa_handler = vec.sv_handler;
1031 OSIG2SIG(vec.sv_mask, nsap->sa_mask);
1032 nsap->sa_flags = vec.sv_flags;
1033 nsap->sa_flags ^= SA_RESTART; /* opposite of SV_INTERRUPT */
1034 }
1035 error = kern_sigaction(td, uap->signum, nsap, osap, KSA_OSIGSET);
1036 if (osap && !error) {
1037 vec.sv_handler = osap->sa_handler;
1038 SIG2OSIG(osap->sa_mask, vec.sv_mask);
1039 vec.sv_flags = osap->sa_flags;
1040 vec.sv_flags &= ~SA_NOCLDWAIT;
1041 vec.sv_flags ^= SA_RESTART;
1042 error = copyout(&vec, uap->osv, sizeof(vec));
1043 }
1044 return (error);
1045}
1046
1047#ifndef _SYS_SYSPROTO_H_
1048struct osigblock_args {
1049 int mask;
--- 39 unchanged lines hidden (view full) ---
1089 SIG_CANTMASK(set);
1090 PROC_LOCK(p);
1091 SIG2OSIG(td->td_sigmask, td->td_retval[0]);
1092 SIGSETLO(td->td_sigmask, set);
1093 signotify(td);
1094 PROC_UNLOCK(p);
1095 return (0);
1096}
1097#endif /* COMPAT_43 */
1098
1099/*
1100 * Suspend process until signal, providing mask to be set
1101 * in the meantime.
1102 ***** XXXKSE this doesn't make sense under KSE.
1103 ***** Do we suspend the thread or all threads in the process?
1104 ***** How do we suspend threads running NOW on another processor?
1105 */
--- 77 unchanged lines hidden (view full) ---
1183 while (msleep(&p->p_sigacts, &p->p_mtx, PPAUSE|PCATCH, "opause", 0) == 0)
1184 /* void */;
1185 PROC_UNLOCK(p);
1186 /* always return EINTR rather than ERESTART... */
1187 return (EINTR);
1188}
1189#endif /* COMPAT_43 */
1190
1191#if defined(COMPAT_43)
1192#ifndef _SYS_SYSPROTO_H_
1193struct osigstack_args {
1194 struct sigstack *nss;
1195 struct sigstack *oss;
1196};
1197#endif
1198/*
1199 * MPSAFE
--- 20 unchanged lines hidden (view full) ---
1220 td->td_sigstk.ss_flags |= nss.ss_onstack & SS_ONSTACK;
1221 td->td_pflags |= TDP_ALTSTACK;
1222 }
1223 if (uap->oss != NULL)
1224 error = copyout(&oss, uap->oss, sizeof(oss));
1225
1226 return (error);
1227}
1228#endif /* COMPAT_43 */
1229
1230#ifndef _SYS_SYSPROTO_H_
1231struct sigaltstack_args {
1232 stack_t *ss;
1233 stack_t *oss;
1234};
1235#endif
1236/*
--- 162 unchanged lines hidden (view full) ---
1399 case 0: /* signal own process group */
1400 return (killpg1(td, uap->signum, 0, 0));
1401 default: /* negative explicit process group */
1402 return (killpg1(td, uap->signum, -uap->pid, 0));
1403 }
1404 /* NOTREACHED */
1405}
1406
1407#if defined(COMPAT_43)
1408#ifndef _SYS_SYSPROTO_H_
1409struct okillpg_args {
1410 int pgid;
1411 int signum;
1412};
1413#endif
1414/*
1415 * MPSAFE
--- 4 unchanged lines hidden (view full) ---
1420 struct thread *td;
1421 register struct okillpg_args *uap;
1422{
1423
1424 if ((u_int)uap->signum > _SIG_MAXSIG)
1425 return (EINVAL);
1426 return (killpg1(td, uap->signum, uap->pgid, 0));
1427}
1428#endif /* COMPAT_43 */
1429
1430/*
1431 * Send a signal to a process group.
1432 */
1433void
1434gsignal(pgid, sig)
1435 int pgid, sig;
1436{
--- 1330 unchanged lines hidden ---
2 * Copyright (c) 1982, 1986, 1989, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.
--- 21 unchanged lines hidden (view full) ---
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)kern_sig.c 8.7 (Berkeley) 4/18/94
35 */
36
37#include <sys/cdefs.h>
38__FBSDID("$FreeBSD: head/sys/kern/kern_sig.c 130344 2004-06-11 11:16:26Z phk $");
39
40#include "opt_compat.h"
41#include "opt_ktrace.h"
42
43#include <sys/param.h>
44#include <sys/systm.h>
45#include <sys/signalvar.h>
46#include <sys/vnode.h>
--- 183 unchanged lines hidden (view full) ---
230}
231
232int
233sigonstack(size_t sp)
234{
235 struct thread *td = curthread;
236
237 return ((td->td_pflags & TDP_ALTSTACK) ?
238#if defined(COMPAT_43)
239 ((td->td_sigstk.ss_size == 0) ?
240 (td->td_sigstk.ss_flags & SS_ONSTACK) :
241 ((sp - (size_t)td->td_sigstk.ss_sp) < td->td_sigstk.ss_size))
242#else
243 ((sp - (size_t)td->td_sigstk.ss_sp) < td->td_sigstk.ss_size)
244#endif
245 : 0);
246}
--- 95 unchanged lines hidden (view full) ---
342 if (act->sa_flags & SA_RESETHAND)
343 SIGADDSET(ps->ps_sigreset, sig);
344 else
345 SIGDELSET(ps->ps_sigreset, sig);
346 if (act->sa_flags & SA_NODEFER)
347 SIGADDSET(ps->ps_signodefer, sig);
348 else
349 SIGDELSET(ps->ps_signodefer, sig);
350 if (sig == SIGCHLD) {
351 if (act->sa_flags & SA_NOCLDSTOP)
352 ps->ps_flag |= PS_NOCLDSTOP;
353 else
354 ps->ps_flag &= ~PS_NOCLDSTOP;
355 if (act->sa_flags & SA_NOCLDWAIT) {
356 /*
357 * Paranoia: since SA_NOCLDWAIT is implemented
--- 631 unchanged lines hidden (view full) ---
989 siglist = p->p_siglist;
990 SIGSETOR(siglist, td->td_siglist);
991 PROC_UNLOCK(p);
992 SIG2OSIG(siglist, td->td_retval[0]);
993 return (0);
994}
995#endif /* COMPAT_43 */
996
997#if defined(COMPAT_43)
998/*
999 * Generalized interface signal handler, 4.3-compatible.
1000 */
1001#ifndef _SYS_SYSPROTO_H_
1002struct osigvec_args {
1003 int signum;
1004 struct sigvec *nsv;
1005 struct sigvec *osv;
--- 20 unchanged lines hidden (view full) ---
1026 if (nsap) {
1027 error = copyin(uap->nsv, &vec, sizeof(vec));
1028 if (error)
1029 return (error);
1030 nsap->sa_handler = vec.sv_handler;
1031 OSIG2SIG(vec.sv_mask, nsap->sa_mask);
1032 nsap->sa_flags = vec.sv_flags;
1033 nsap->sa_flags ^= SA_RESTART; /* opposite of SV_INTERRUPT */
1034 }
1035 error = kern_sigaction(td, uap->signum, nsap, osap, KSA_OSIGSET);
1036 if (osap && !error) {
1037 vec.sv_handler = osap->sa_handler;
1038 SIG2OSIG(osap->sa_mask, vec.sv_mask);
1039 vec.sv_flags = osap->sa_flags;
1040 vec.sv_flags &= ~SA_NOCLDWAIT;
1041 vec.sv_flags ^= SA_RESTART;
1042 error = copyout(&vec, uap->osv, sizeof(vec));
1043 }
1044 return (error);
1045}
1046
1047#ifndef _SYS_SYSPROTO_H_
1048struct osigblock_args {
1049 int mask;
--- 39 unchanged lines hidden (view full) ---
1089 SIG_CANTMASK(set);
1090 PROC_LOCK(p);
1091 SIG2OSIG(td->td_sigmask, td->td_retval[0]);
1092 SIGSETLO(td->td_sigmask, set);
1093 signotify(td);
1094 PROC_UNLOCK(p);
1095 return (0);
1096}
1097#endif /* COMPAT_43 */
1098
1099/*
1100 * Suspend process until signal, providing mask to be set
1101 * in the meantime.
1102 ***** XXXKSE this doesn't make sense under KSE.
1103 ***** Do we suspend the thread or all threads in the process?
1104 ***** How do we suspend threads running NOW on another processor?
1105 */
--- 77 unchanged lines hidden (view full) ---
1183 while (msleep(&p->p_sigacts, &p->p_mtx, PPAUSE|PCATCH, "opause", 0) == 0)
1184 /* void */;
1185 PROC_UNLOCK(p);
1186 /* always return EINTR rather than ERESTART... */
1187 return (EINTR);
1188}
1189#endif /* COMPAT_43 */
1190
1191#if defined(COMPAT_43)
1192#ifndef _SYS_SYSPROTO_H_
1193struct osigstack_args {
1194 struct sigstack *nss;
1195 struct sigstack *oss;
1196};
1197#endif
1198/*
1199 * MPSAFE
--- 20 unchanged lines hidden (view full) ---
1220 td->td_sigstk.ss_flags |= nss.ss_onstack & SS_ONSTACK;
1221 td->td_pflags |= TDP_ALTSTACK;
1222 }
1223 if (uap->oss != NULL)
1224 error = copyout(&oss, uap->oss, sizeof(oss));
1225
1226 return (error);
1227}
1228#endif /* COMPAT_43 */
1229
1230#ifndef _SYS_SYSPROTO_H_
1231struct sigaltstack_args {
1232 stack_t *ss;
1233 stack_t *oss;
1234};
1235#endif
1236/*
--- 162 unchanged lines hidden (view full) ---
1399 case 0: /* signal own process group */
1400 return (killpg1(td, uap->signum, 0, 0));
1401 default: /* negative explicit process group */
1402 return (killpg1(td, uap->signum, -uap->pid, 0));
1403 }
1404 /* NOTREACHED */
1405}
1406
1407#if defined(COMPAT_43)
1408#ifndef _SYS_SYSPROTO_H_
1409struct okillpg_args {
1410 int pgid;
1411 int signum;
1412};
1413#endif
1414/*
1415 * MPSAFE
--- 4 unchanged lines hidden (view full) ---
1420 struct thread *td;
1421 register struct okillpg_args *uap;
1422{
1423
1424 if ((u_int)uap->signum > _SIG_MAXSIG)
1425 return (EINVAL);
1426 return (killpg1(td, uap->signum, uap->pgid, 0));
1427}
1428#endif /* COMPAT_43 */
1429
1430/*
1431 * Send a signal to a process group.
1432 */
1433void
1434gsignal(pgid, sig)
1435 int pgid, sig;
1436{
--- 1330 unchanged lines hidden ---