kern_sig.c (1e41c1b5d5b85c597eb6105e6ee35dc096507c8e) | kern_sig.c (d2d3e8751c3b7831f7064ccf400978b75b696547) |
---|---|
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. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)kern_sig.c 8.7 (Berkeley) 4/18/94 | 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. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)kern_sig.c 8.7 (Berkeley) 4/18/94 |
39 * $Id: kern_sig.c,v 1.11 1995/05/30 08:05:40 rgrimes Exp $ | 39 * $Id: kern_sig.c,v 1.12 1995/10/19 19:15:23 swallace Exp $ |
40 */ 41 42#define SIGPROP /* include signal properties table */ 43#include <sys/param.h> | 40 */ 41 42#define SIGPROP /* include signal properties table */ 43#include <sys/param.h> |
44#include <sys/sysproto.h> |
|
44#include <sys/signalvar.h> 45#include <sys/resourcevar.h> 46#include <sys/namei.h> 47#include <sys/vnode.h> 48#include <sys/proc.h> 49#include <sys/systm.h> 50#include <sys/timeb.h> 51#include <sys/times.h> --- 20 unchanged lines hidden (view full) --- 72#define CANSIGNAL(p, pc, q, signum) \ 73 ((pc)->pc_ucred->cr_uid == 0 || \ 74 (pc)->p_ruid == (q)->p_cred->p_ruid || \ 75 (pc)->pc_ucred->cr_uid == (q)->p_cred->p_ruid || \ 76 (pc)->p_ruid == (q)->p_ucred->cr_uid || \ 77 (pc)->pc_ucred->cr_uid == (q)->p_ucred->cr_uid || \ 78 ((signum) == SIGCONT && (q)->p_session == (p)->p_session)) 79 | 45#include <sys/signalvar.h> 46#include <sys/resourcevar.h> 47#include <sys/namei.h> 48#include <sys/vnode.h> 49#include <sys/proc.h> 50#include <sys/systm.h> 51#include <sys/timeb.h> 52#include <sys/times.h> --- 20 unchanged lines hidden (view full) --- 73#define CANSIGNAL(p, pc, q, signum) \ 74 ((pc)->pc_ucred->cr_uid == 0 || \ 75 (pc)->p_ruid == (q)->p_cred->p_ruid || \ 76 (pc)->pc_ucred->cr_uid == (q)->p_cred->p_ruid || \ 77 (pc)->p_ruid == (q)->p_ucred->cr_uid || \ 78 (pc)->pc_ucred->cr_uid == (q)->p_ucred->cr_uid || \ 79 ((signum) == SIGCONT && (q)->p_session == (p)->p_session)) 80 |
81#ifndef _SYS_SYSPROTO_H_ |
|
80struct sigaction_args { 81 int signum; 82 struct sigaction *nsa; 83 struct sigaction *osa; 84}; | 82struct sigaction_args { 83 int signum; 84 struct sigaction *nsa; 85 struct sigaction *osa; 86}; |
87#endif |
|
85/* ARGSUSED */ 86int 87sigaction(p, uap, retval) 88 struct proc *p; 89 register struct sigaction_args *uap; 90 int *retval; 91{ 92 struct sigaction vec; --- 147 unchanged lines hidden (view full) --- 240} 241 242/* 243 * Manipulate signal mask. 244 * Note that we receive new mask, not pointer, 245 * and return old mask as return value; 246 * the library stub does the rest. 247 */ | 88/* ARGSUSED */ 89int 90sigaction(p, uap, retval) 91 struct proc *p; 92 register struct sigaction_args *uap; 93 int *retval; 94{ 95 struct sigaction vec; --- 147 unchanged lines hidden (view full) --- 243} 244 245/* 246 * Manipulate signal mask. 247 * Note that we receive new mask, not pointer, 248 * and return old mask as return value; 249 * the library stub does the rest. 250 */ |
251#ifndef _SYS_SYSPROTO_H_ |
|
248struct sigprocmask_args { 249 int how; 250 sigset_t mask; 251}; | 252struct sigprocmask_args { 253 int how; 254 sigset_t mask; 255}; |
256#endif |
|
252int 253sigprocmask(p, uap, retval) 254 register struct proc *p; 255 struct sigprocmask_args *uap; 256 int *retval; 257{ 258 int error = 0; 259 --- 16 unchanged lines hidden (view full) --- 276 default: 277 error = EINVAL; 278 break; 279 } 280 (void) spl0(); 281 return (error); 282} 283 | 257int 258sigprocmask(p, uap, retval) 259 register struct proc *p; 260 struct sigprocmask_args *uap; 261 int *retval; 262{ 263 int error = 0; 264 --- 16 unchanged lines hidden (view full) --- 281 default: 282 error = EINVAL; 283 break; 284 } 285 (void) spl0(); 286 return (error); 287} 288 |
289#ifndef _SYS_SYSPROTO_H_ |
|
284struct sigpending_args { 285 int dummy; 286}; | 290struct sigpending_args { 291 int dummy; 292}; |
293#endif |
|
287/* ARGSUSED */ 288int 289sigpending(p, uap, retval) 290 struct proc *p; 291 struct sigpending_args *uap; 292 int *retval; 293{ 294 295 *retval = p->p_siglist; 296 return (0); 297} 298 299#if defined(COMPAT_43) || defined(COMPAT_SUNOS) 300/* 301 * Generalized interface signal handler, 4.3-compatible. 302 */ | 294/* ARGSUSED */ 295int 296sigpending(p, uap, retval) 297 struct proc *p; 298 struct sigpending_args *uap; 299 int *retval; 300{ 301 302 *retval = p->p_siglist; 303 return (0); 304} 305 306#if defined(COMPAT_43) || defined(COMPAT_SUNOS) 307/* 308 * Generalized interface signal handler, 4.3-compatible. 309 */ |
310#ifndef _SYS_SYSPROTO_H_ |
|
303struct osigvec_args { 304 int signum; 305 struct sigvec *nsv; 306 struct sigvec *osv; 307}; | 311struct osigvec_args { 312 int signum; 313 struct sigvec *nsv; 314 struct sigvec *osv; 315}; |
316#endif |
|
308/* ARGSUSED */ 309int 310osigvec(p, uap, retval) 311 struct proc *p; 312 register struct osigvec_args *uap; 313 int *retval; 314{ 315 struct sigvec vec; --- 39 unchanged lines hidden (view full) --- 355 sv->sv_flags |= SA_USERTRAMP; 356#endif 357 sv->sv_flags ^= SA_RESTART; /* opposite of SV_INTERRUPT */ 358 setsigvec(p, signum, (struct sigaction *)sv); 359 } 360 return (0); 361} 362 | 317/* ARGSUSED */ 318int 319osigvec(p, uap, retval) 320 struct proc *p; 321 register struct osigvec_args *uap; 322 int *retval; 323{ 324 struct sigvec vec; --- 39 unchanged lines hidden (view full) --- 364 sv->sv_flags |= SA_USERTRAMP; 365#endif 366 sv->sv_flags ^= SA_RESTART; /* opposite of SV_INTERRUPT */ 367 setsigvec(p, signum, (struct sigaction *)sv); 368 } 369 return (0); 370} 371 |
372#ifndef _SYS_SYSPROTO_H_ |
|
363struct osigblock_args { 364 int mask; 365}; | 373struct osigblock_args { 374 int mask; 375}; |
376#endif |
|
366int 367osigblock(p, uap, retval) 368 register struct proc *p; 369 struct osigblock_args *uap; 370 int *retval; 371{ 372 373 (void) splhigh(); 374 *retval = p->p_sigmask; 375 p->p_sigmask |= uap->mask &~ sigcantmask; 376 (void) spl0(); 377 return (0); 378} 379 | 377int 378osigblock(p, uap, retval) 379 register struct proc *p; 380 struct osigblock_args *uap; 381 int *retval; 382{ 383 384 (void) splhigh(); 385 *retval = p->p_sigmask; 386 p->p_sigmask |= uap->mask &~ sigcantmask; 387 (void) spl0(); 388 return (0); 389} 390 |
391#ifndef _SYS_SYSPROTO_H_ |
|
380struct osigsetmask_args { 381 int mask; 382}; | 392struct osigsetmask_args { 393 int mask; 394}; |
395#endif |
|
383int 384osigsetmask(p, uap, retval) 385 struct proc *p; 386 struct osigsetmask_args *uap; 387 int *retval; 388{ 389 390 (void) splhigh(); --- 4 unchanged lines hidden (view full) --- 395} 396#endif /* COMPAT_43 || COMPAT_SUNOS */ 397 398/* 399 * Suspend process until signal, providing mask to be set 400 * in the meantime. Note nonstandard calling convention: 401 * libc stub passes mask, not pointer, to save a copyin. 402 */ | 396int 397osigsetmask(p, uap, retval) 398 struct proc *p; 399 struct osigsetmask_args *uap; 400 int *retval; 401{ 402 403 (void) splhigh(); --- 4 unchanged lines hidden (view full) --- 408} 409#endif /* COMPAT_43 || COMPAT_SUNOS */ 410 411/* 412 * Suspend process until signal, providing mask to be set 413 * in the meantime. Note nonstandard calling convention: 414 * libc stub passes mask, not pointer, to save a copyin. 415 */ |
416#ifndef _SYS_SYSPROTO_H_ |
|
403struct sigsuspend_args { 404 sigset_t mask; 405}; | 417struct sigsuspend_args { 418 sigset_t mask; 419}; |
420#endif |
|
406/* ARGSUSED */ 407int 408sigsuspend(p, uap, retval) 409 register struct proc *p; 410 struct sigsuspend_args *uap; 411 int *retval; 412{ 413 register struct sigacts *ps = p->p_sigacts; --- 10 unchanged lines hidden (view full) --- 424 p->p_sigmask = uap->mask &~ sigcantmask; 425 while (tsleep((caddr_t) ps, PPAUSE|PCATCH, "pause", 0) == 0) 426 /* void */; 427 /* always return EINTR rather than ERESTART... */ 428 return (EINTR); 429} 430 431#if defined(COMPAT_43) || defined(COMPAT_SUNOS) | 421/* ARGSUSED */ 422int 423sigsuspend(p, uap, retval) 424 register struct proc *p; 425 struct sigsuspend_args *uap; 426 int *retval; 427{ 428 register struct sigacts *ps = p->p_sigacts; --- 10 unchanged lines hidden (view full) --- 439 p->p_sigmask = uap->mask &~ sigcantmask; 440 while (tsleep((caddr_t) ps, PPAUSE|PCATCH, "pause", 0) == 0) 441 /* void */; 442 /* always return EINTR rather than ERESTART... */ 443 return (EINTR); 444} 445 446#if defined(COMPAT_43) || defined(COMPAT_SUNOS) |
447#ifndef _SYS_SYSPROTO_H_ |
|
432struct osigstack_args { 433 struct sigstack *nss; 434 struct sigstack *oss; 435}; | 448struct osigstack_args { 449 struct sigstack *nss; 450 struct sigstack *oss; 451}; |
452#endif |
|
436/* ARGSUSED */ 437int 438osigstack(p, uap, retval) 439 struct proc *p; 440 register struct osigstack_args *uap; 441 int *retval; 442{ 443 struct sigstack ss; --- 12 unchanged lines hidden (view full) --- 456 psp->ps_sigstk.ss_size = 0; 457 psp->ps_sigstk.ss_flags |= ss.ss_onstack & SA_ONSTACK; 458 psp->ps_flags |= SAS_ALTSTACK; 459 } 460 return (error); 461} 462#endif /* COMPAT_43 || COMPAT_SUNOS */ 463 | 453/* ARGSUSED */ 454int 455osigstack(p, uap, retval) 456 struct proc *p; 457 register struct osigstack_args *uap; 458 int *retval; 459{ 460 struct sigstack ss; --- 12 unchanged lines hidden (view full) --- 473 psp->ps_sigstk.ss_size = 0; 474 psp->ps_sigstk.ss_flags |= ss.ss_onstack & SA_ONSTACK; 475 psp->ps_flags |= SAS_ALTSTACK; 476 } 477 return (error); 478} 479#endif /* COMPAT_43 || COMPAT_SUNOS */ 480 |
481#ifndef _SYS_SYSPROTO_H_ |
|
464struct sigaltstack_args { 465 struct sigaltstack *nss; 466 struct sigaltstack *oss; 467}; | 482struct sigaltstack_args { 483 struct sigaltstack *nss; 484 struct sigaltstack *oss; 485}; |
486#endif |
|
468/* ARGSUSED */ 469int 470sigaltstack(p, uap, retval) 471 struct proc *p; 472 register struct sigaltstack_args *uap; 473 int *retval; 474{ 475 struct sigacts *psp; --- 69 unchanged lines hidden (view full) --- 545 nfound++; 546 if (signum) 547 psignal(p, signum); 548 } 549 } 550 return (nfound ? 0 : ESRCH); 551} 552 | 487/* ARGSUSED */ 488int 489sigaltstack(p, uap, retval) 490 struct proc *p; 491 register struct sigaltstack_args *uap; 492 int *retval; 493{ 494 struct sigacts *psp; --- 69 unchanged lines hidden (view full) --- 564 nfound++; 565 if (signum) 566 psignal(p, signum); 567 } 568 } 569 return (nfound ? 0 : ESRCH); 570} 571 |
572#ifndef _SYS_SYSPROTO_H_ |
|
553struct kill_args { 554 int pid; 555 int signum; 556}; | 573struct kill_args { 574 int pid; 575 int signum; 576}; |
577#endif |
|
557/* ARGSUSED */ 558int 559kill(cp, uap, retval) 560 register struct proc *cp; 561 register struct kill_args *uap; 562 int *retval; 563{ 564 register struct proc *p; --- 18 unchanged lines hidden (view full) --- 583 return (killpg1(cp, uap->signum, 0, 0)); 584 default: /* negative explicit process group */ 585 return (killpg1(cp, uap->signum, -uap->pid, 0)); 586 } 587 /* NOTREACHED */ 588} 589 590#if defined(COMPAT_43) || defined(COMPAT_SUNOS) | 578/* ARGSUSED */ 579int 580kill(cp, uap, retval) 581 register struct proc *cp; 582 register struct kill_args *uap; 583 int *retval; 584{ 585 register struct proc *p; --- 18 unchanged lines hidden (view full) --- 604 return (killpg1(cp, uap->signum, 0, 0)); 605 default: /* negative explicit process group */ 606 return (killpg1(cp, uap->signum, -uap->pid, 0)); 607 } 608 /* NOTREACHED */ 609} 610 611#if defined(COMPAT_43) || defined(COMPAT_SUNOS) |
612#ifndef _SYS_SYSPROTO_H_ |
|
591struct okillpg_args { 592 int pgid; 593 int signum; 594}; | 613struct okillpg_args { 614 int pgid; 615 int signum; 616}; |
617#endif |
|
595/* ARGSUSED */ 596int 597okillpg(p, uap, retval) 598 struct proc *p; 599 register struct okillpg_args *uap; 600 int *retval; 601{ 602 --- 613 unchanged lines hidden (view full) --- 1216 error = error1; 1217 return (error); 1218} 1219 1220/* 1221 * Nonexistent system call-- signal process (may want to handle it). 1222 * Flag error in case process won't see signal immediately (blocked or ignored). 1223 */ | 618/* ARGSUSED */ 619int 620okillpg(p, uap, retval) 621 struct proc *p; 622 register struct okillpg_args *uap; 623 int *retval; 624{ 625 --- 613 unchanged lines hidden (view full) --- 1239 error = error1; 1240 return (error); 1241} 1242 1243/* 1244 * Nonexistent system call-- signal process (may want to handle it). 1245 * Flag error in case process won't see signal immediately (blocked or ignored). 1246 */ |
1247#ifndef _SYS_SYSPROTO_H_ |
|
1224struct nosys_args { 1225 int dummy; 1226}; | 1248struct nosys_args { 1249 int dummy; 1250}; |
1251#endif |
|
1227/* ARGSUSED */ 1228int 1229nosys(p, args, retval) 1230 struct proc *p; 1231 struct nosys_args *args; 1232 int *retval; 1233{ 1234 1235 psignal(p, SIGSYS); 1236 return (EINVAL); 1237} | 1252/* ARGSUSED */ 1253int 1254nosys(p, args, retval) 1255 struct proc *p; 1256 struct nosys_args *args; 1257 int *retval; 1258{ 1259 1260 psignal(p, SIGSYS); 1261 return (EINVAL); 1262} |