kern_sig.c (179235b38b56f8006e208d42bcff09a0393191b7) | kern_sig.c (79065dba2a88baf780767cbb1bb31d4525a08528) |
---|---|
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. --- 166 unchanged lines hidden (view full) --- 175CURSIG(struct proc *p) 176{ 177 178 PROC_LOCK_ASSERT(p, MA_OWNED); 179 mtx_assert(&sched_lock, MA_NOTOWNED); 180 return (SIGPENDING(p) ? issignal(p) : 0); 181} 182 | 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. --- 166 unchanged lines hidden (view full) --- 175CURSIG(struct proc *p) 176{ 177 178 PROC_LOCK_ASSERT(p, MA_OWNED); 179 mtx_assert(&sched_lock, MA_NOTOWNED); 180 return (SIGPENDING(p) ? issignal(p) : 0); 181} 182 |
183/* 184 * Arrange for ast() to handle unmasked pending signals on return to user 185 * mode. This must be called whenever a signal is added to p_siglist or 186 * unmasked in p_sigmask. 187 */ 188void 189signotify(struct proc *p) 190{ 191 192 PROC_LOCK_ASSERT(p, MA_OWNED); 193 mtx_assert(&sched_lock, MA_NOTOWNED); 194 mtx_lock_spin(&sched_lock); 195 if (SIGPENDING(p)) { 196 p->p_sflag |= PS_NEEDSIGCHK; 197 p->p_kse.ke_flags |= KEF_ASTPENDING; /* XXXKSE */ 198 } 199 mtx_unlock_spin(&sched_lock); 200} 201 |
|
183static __inline int 184sigprop(int sig) 185{ 186 187 if (sig > 0 && sig < NSIG) 188 return (sigproptbl[_SIG_IDX(sig)]); 189 return (0); 190} --- 318 unchanged lines hidden (view full) --- 509 if (set != NULL) { 510 switch (how) { 511 case SIG_BLOCK: 512 SIG_CANTMASK(*set); 513 SIGSETOR(p->p_sigmask, *set); 514 break; 515 case SIG_UNBLOCK: 516 SIGSETNAND(p->p_sigmask, *set); | 202static __inline int 203sigprop(int sig) 204{ 205 206 if (sig > 0 && sig < NSIG) 207 return (sigproptbl[_SIG_IDX(sig)]); 208 return (0); 209} --- 318 unchanged lines hidden (view full) --- 528 if (set != NULL) { 529 switch (how) { 530 case SIG_BLOCK: 531 SIG_CANTMASK(*set); 532 SIGSETOR(p->p_sigmask, *set); 533 break; 534 case SIG_UNBLOCK: 535 SIGSETNAND(p->p_sigmask, *set); |
536 signotify(p); |
|
517 break; 518 case SIG_SETMASK: 519 SIG_CANTMASK(*set); 520 if (old) 521 SIGSETLO(p->p_sigmask, *set); 522 else 523 p->p_sigmask = *set; | 537 break; 538 case SIG_SETMASK: 539 SIG_CANTMASK(*set); 540 if (old) 541 SIGSETLO(p->p_sigmask, *set); 542 else 543 p->p_sigmask = *set; |
544 signotify(p); |
|
524 break; 525 default: 526 error = EINVAL; 527 break; 528 } 529 } 530 PROC_UNLOCK(p); 531 return (error); --- 216 unchanged lines hidden (view full) --- 748 sigset_t set; 749 750 OSIG2SIG(uap->mask, set); 751 SIG_CANTMASK(set); 752 mtx_lock(&Giant); 753 PROC_LOCK(p); 754 SIG2OSIG(p->p_sigmask, td->td_retval[0]); 755 SIGSETLO(p->p_sigmask, set); | 545 break; 546 default: 547 error = EINVAL; 548 break; 549 } 550 } 551 PROC_UNLOCK(p); 552 return (error); --- 216 unchanged lines hidden (view full) --- 769 sigset_t set; 770 771 OSIG2SIG(uap->mask, set); 772 SIG_CANTMASK(set); 773 mtx_lock(&Giant); 774 PROC_LOCK(p); 775 SIG2OSIG(p->p_sigmask, td->td_retval[0]); 776 SIGSETLO(p->p_sigmask, set); |
777 signotify(p); |
|
756 PROC_UNLOCK(p); 757 mtx_unlock(&Giant); 758 return (0); 759} 760#endif /* COMPAT_43 || COMPAT_SUNOS */ 761 762/* 763 * Suspend process until signal, providing mask to be set --- 36 unchanged lines hidden (view full) --- 800 mtx_lock(&Giant); 801 PROC_LOCK(p); 802 ps = p->p_sigacts; 803 p->p_oldsigmask = p->p_sigmask; 804 p->p_flag |= P_OLDMASK; 805 806 SIG_CANTMASK(mask); 807 p->p_sigmask = mask; | 778 PROC_UNLOCK(p); 779 mtx_unlock(&Giant); 780 return (0); 781} 782#endif /* COMPAT_43 || COMPAT_SUNOS */ 783 784/* 785 * Suspend process until signal, providing mask to be set --- 36 unchanged lines hidden (view full) --- 822 mtx_lock(&Giant); 823 PROC_LOCK(p); 824 ps = p->p_sigacts; 825 p->p_oldsigmask = p->p_sigmask; 826 p->p_flag |= P_OLDMASK; 827 828 SIG_CANTMASK(mask); 829 p->p_sigmask = mask; |
830 signotify(p); |
|
808 while (msleep((caddr_t) ps, &p->p_mtx, PPAUSE|PCATCH, "pause", 0) == 0) 809 /* void */; 810 PROC_UNLOCK(p); 811 mtx_unlock(&Giant); 812 /* always return EINTR rather than ERESTART... */ 813 return (EINTR); 814} 815 --- 19 unchanged lines hidden (view full) --- 835 mtx_lock(&Giant); 836 PROC_LOCK(p); 837 ps = p->p_sigacts; 838 p->p_oldsigmask = p->p_sigmask; 839 p->p_flag |= P_OLDMASK; 840 OSIG2SIG(uap->mask, mask); 841 SIG_CANTMASK(mask); 842 SIGSETLO(p->p_sigmask, mask); | 831 while (msleep((caddr_t) ps, &p->p_mtx, PPAUSE|PCATCH, "pause", 0) == 0) 832 /* void */; 833 PROC_UNLOCK(p); 834 mtx_unlock(&Giant); 835 /* always return EINTR rather than ERESTART... */ 836 return (EINTR); 837} 838 --- 19 unchanged lines hidden (view full) --- 858 mtx_lock(&Giant); 859 PROC_LOCK(p); 860 ps = p->p_sigacts; 861 p->p_oldsigmask = p->p_sigmask; 862 p->p_flag |= P_OLDMASK; 863 OSIG2SIG(uap->mask, mask); 864 SIG_CANTMASK(mask); 865 SIGSETLO(p->p_sigmask, mask); |
866 signotify(p); |
|
843 while (msleep((caddr_t) ps, &p->p_mtx, PPAUSE|PCATCH, "opause", 0) == 0) 844 /* void */; 845 PROC_UNLOCK(p); 846 mtx_unlock(&Giant); 847 /* always return EINTR rather than ERESTART... */ 848 return (EINTR); 849} 850#endif /* COMPAT_43 */ --- 447 unchanged lines hidden (view full) --- 1298 * and don't clear any pending SIGCONT. 1299 */ 1300 if (prop & SA_TTYSTOP && p->p_pgrp->pg_jobc == 0 && 1301 action == SIG_DFL) 1302 return; 1303 SIG_CONTSIGMASK(p->p_siglist); 1304 } 1305 SIGADDSET(p->p_siglist, sig); | 867 while (msleep((caddr_t) ps, &p->p_mtx, PPAUSE|PCATCH, "opause", 0) == 0) 868 /* void */; 869 PROC_UNLOCK(p); 870 mtx_unlock(&Giant); 871 /* always return EINTR rather than ERESTART... */ 872 return (EINTR); 873} 874#endif /* COMPAT_43 */ --- 447 unchanged lines hidden (view full) --- 1322 * and don't clear any pending SIGCONT. 1323 */ 1324 if (prop & SA_TTYSTOP && p->p_pgrp->pg_jobc == 0 && 1325 action == SIG_DFL) 1326 return; 1327 SIG_CONTSIGMASK(p->p_siglist); 1328 } 1329 SIGADDSET(p->p_siglist, sig); |
1330 signotify(p); |
|
1306 1307 /* 1308 * Defer further processing for signals which are held, 1309 * except that stopped processes must be continued by SIGCONT. 1310 */ 1311 mtx_lock_spin(&sched_lock); 1312 if (action == SIG_HOLD && (!(prop & SA_CONT) || p->p_stat != SSTOP)) { 1313 mtx_unlock_spin(&sched_lock); --- 156 unchanged lines hidden (view full) --- 1470 * SRUN, SIDL, SZOMB do nothing with the signal, 1471 * other than kicking ourselves if we are running. 1472 * It will either never be noticed, or noticed very soon. 1473 */ 1474 if (p->p_stat == SRUN) { 1475#ifdef SMP 1476 struct kse *ke; 1477 struct thread *td = curthread; | 1331 1332 /* 1333 * Defer further processing for signals which are held, 1334 * except that stopped processes must be continued by SIGCONT. 1335 */ 1336 mtx_lock_spin(&sched_lock); 1337 if (action == SIG_HOLD && (!(prop & SA_CONT) || p->p_stat != SSTOP)) { 1338 mtx_unlock_spin(&sched_lock); --- 156 unchanged lines hidden (view full) --- 1495 * SRUN, SIDL, SZOMB do nothing with the signal, 1496 * other than kicking ourselves if we are running. 1497 * It will either never be noticed, or noticed very soon. 1498 */ 1499 if (p->p_stat == SRUN) { 1500#ifdef SMP 1501 struct kse *ke; 1502 struct thread *td = curthread; |
1478 signotify(&p->p_kse); /* XXXKSE */ | |
1479/* we should only deliver to one thread.. but which one? */ 1480 FOREACH_KSEGRP_IN_PROC(p, kg) { 1481 FOREACH_KSE_IN_GROUP(kg, ke) { 1482 if (ke->ke_thread == td) { 1483 continue; 1484 } 1485 forward_signal(ke->ke_thread); 1486 } 1487 } | 1503/* we should only deliver to one thread.. but which one? */ 1504 FOREACH_KSEGRP_IN_PROC(p, kg) { 1505 FOREACH_KSE_IN_GROUP(kg, ke) { 1506 if (ke->ke_thread == td) { 1507 continue; 1508 } 1509 forward_signal(ke->ke_thread); 1510 } 1511 } |
1488#else 1489 signotify(&p->p_kse); /* XXXKSE */ | |
1490#endif 1491 } 1492 mtx_unlock_spin(&sched_lock); 1493 goto out; 1494 } 1495 /*NOTREACHED*/ 1496 1497runfast: --- 651 unchanged lines hidden --- | 1512#endif 1513 } 1514 mtx_unlock_spin(&sched_lock); 1515 goto out; 1516 } 1517 /*NOTREACHED*/ 1518 1519runfast: --- 651 unchanged lines hidden --- |