Deleted Added
full compact
kern_sig.c (130192) kern_sig.c (130344)
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>
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 130192 2004-06-07 13:35:02Z davidxu $");
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) ?
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) || defined(COMPAT_SUNOS)
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);
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#ifdef COMPAT_SUNOS
351 if (act->sa_flags & SA_USERTRAMP)
352 SIGADDSET(ps->ps_usertramp, sig);
353 else
354 SIGDELSET(ps->ps_usertramp, sig);
355#endif
356 if (sig == SIGCHLD) {
357 if (act->sa_flags & SA_NOCLDSTOP)
358 ps->ps_flag |= PS_NOCLDSTOP;
359 else
360 ps->ps_flag &= ~PS_NOCLDSTOP;
361 if (act->sa_flags & SA_NOCLDWAIT) {
362 /*
363 * Paranoia: since SA_NOCLDWAIT is implemented

--- 631 unchanged lines hidden (view full) ---

995 siglist = p->p_siglist;
996 SIGSETOR(siglist, td->td_siglist);
997 PROC_UNLOCK(p);
998 SIG2OSIG(siglist, td->td_retval[0]);
999 return (0);
1000}
1001#endif /* COMPAT_43 */
1002
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
1003#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
997#if defined(COMPAT_43)
1004/*
1005 * Generalized interface signal handler, 4.3-compatible.
1006 */
1007#ifndef _SYS_SYSPROTO_H_
1008struct osigvec_args {
1009 int signum;
1010 struct sigvec *nsv;
1011 struct sigvec *osv;

--- 20 unchanged lines hidden (view full) ---

1032 if (nsap) {
1033 error = copyin(uap->nsv, &vec, sizeof(vec));
1034 if (error)
1035 return (error);
1036 nsap->sa_handler = vec.sv_handler;
1037 OSIG2SIG(vec.sv_mask, nsap->sa_mask);
1038 nsap->sa_flags = vec.sv_flags;
1039 nsap->sa_flags ^= SA_RESTART; /* opposite of SV_INTERRUPT */
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 */
1040#ifdef COMPAT_SUNOS
1041 nsap->sa_flags |= SA_USERTRAMP;
1042#endif
1043 }
1044 error = kern_sigaction(td, uap->signum, nsap, osap, KSA_OSIGSET);
1045 if (osap && !error) {
1046 vec.sv_handler = osap->sa_handler;
1047 SIG2OSIG(osap->sa_mask, vec.sv_mask);
1048 vec.sv_flags = osap->sa_flags;
1049 vec.sv_flags &= ~SA_NOCLDWAIT;
1050 vec.sv_flags ^= SA_RESTART;
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;
1051#ifdef COMPAT_SUNOS
1052 vec.sv_flags &= ~SA_NOCLDSTOP;
1053#endif
1054 error = copyout(&vec, uap->osv, sizeof(vec));
1055 }
1056 return (error);
1057}
1058
1059#ifndef _SYS_SYSPROTO_H_
1060struct osigblock_args {
1061 int mask;

--- 39 unchanged lines hidden (view full) ---

1101 SIG_CANTMASK(set);
1102 PROC_LOCK(p);
1103 SIG2OSIG(td->td_sigmask, td->td_retval[0]);
1104 SIGSETLO(td->td_sigmask, set);
1105 signotify(td);
1106 PROC_UNLOCK(p);
1107 return (0);
1108}
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}
1109#endif /* COMPAT_43 || COMPAT_SUNOS */
1097#endif /* COMPAT_43 */
1110
1111/*
1112 * Suspend process until signal, providing mask to be set
1113 * in the meantime.
1114 ***** XXXKSE this doesn't make sense under KSE.
1115 ***** Do we suspend the thread or all threads in the process?
1116 ***** How do we suspend threads running NOW on another processor?
1117 */

--- 77 unchanged lines hidden (view full) ---

1195 while (msleep(&p->p_sigacts, &p->p_mtx, PPAUSE|PCATCH, "opause", 0) == 0)
1196 /* void */;
1197 PROC_UNLOCK(p);
1198 /* always return EINTR rather than ERESTART... */
1199 return (EINTR);
1200}
1201#endif /* COMPAT_43 */
1202
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
1203#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
1191#if defined(COMPAT_43)
1204#ifndef _SYS_SYSPROTO_H_
1205struct osigstack_args {
1206 struct sigstack *nss;
1207 struct sigstack *oss;
1208};
1209#endif
1210/*
1211 * MPSAFE

--- 20 unchanged lines hidden (view full) ---

1232 td->td_sigstk.ss_flags |= nss.ss_onstack & SS_ONSTACK;
1233 td->td_pflags |= TDP_ALTSTACK;
1234 }
1235 if (uap->oss != NULL)
1236 error = copyout(&oss, uap->oss, sizeof(oss));
1237
1238 return (error);
1239}
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}
1240#endif /* COMPAT_43 || COMPAT_SUNOS */
1228#endif /* COMPAT_43 */
1241
1242#ifndef _SYS_SYSPROTO_H_
1243struct sigaltstack_args {
1244 stack_t *ss;
1245 stack_t *oss;
1246};
1247#endif
1248/*

--- 162 unchanged lines hidden (view full) ---

1411 case 0: /* signal own process group */
1412 return (killpg1(td, uap->signum, 0, 0));
1413 default: /* negative explicit process group */
1414 return (killpg1(td, uap->signum, -uap->pid, 0));
1415 }
1416 /* NOTREACHED */
1417}
1418
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
1419#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
1407#if defined(COMPAT_43)
1420#ifndef _SYS_SYSPROTO_H_
1421struct okillpg_args {
1422 int pgid;
1423 int signum;
1424};
1425#endif
1426/*
1427 * MPSAFE

--- 4 unchanged lines hidden (view full) ---

1432 struct thread *td;
1433 register struct okillpg_args *uap;
1434{
1435
1436 if ((u_int)uap->signum > _SIG_MAXSIG)
1437 return (EINVAL);
1438 return (killpg1(td, uap->signum, uap->pgid, 0));
1439}
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}
1440#endif /* COMPAT_43 || COMPAT_SUNOS */
1428#endif /* COMPAT_43 */
1441
1442/*
1443 * Send a signal to a process group.
1444 */
1445void
1446gsignal(pgid, sig)
1447 int pgid, sig;
1448{

--- 1330 unchanged lines hidden ---
1429
1430/*
1431 * Send a signal to a process group.
1432 */
1433void
1434gsignal(pgid, sig)
1435 int pgid, sig;
1436{

--- 1330 unchanged lines hidden ---