Annotation of sys/compat/svr4/svr4_signal.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: svr4_signal.c,v 1.10 2002/03/14 01:26:51 millert Exp $ */
! 2: /* $NetBSD: svr4_signal.c,v 1.24 1996/12/06 03:21:53 christos Exp $ */
! 3:
! 4: /*
! 5: * Copyright (c) 1994 Christos Zoulas
! 6: * All rights reserved.
! 7: *
! 8: * Redistribution and use in source and binary forms, with or without
! 9: * modification, are permitted provided that the following conditions
! 10: * are met:
! 11: * 1. Redistributions of source code must retain the above copyright
! 12: * notice, this list of conditions and the following disclaimer.
! 13: * 2. Redistributions in binary form must reproduce the above copyright
! 14: * notice, this list of conditions and the following disclaimer in the
! 15: * documentation and/or other materials provided with the distribution.
! 16: * 3. The name of the author may not be used to endorse or promote products
! 17: * derived from this software without specific prior written permission
! 18: *
! 19: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
! 20: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
! 21: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
! 22: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
! 23: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
! 24: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
! 25: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
! 26: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
! 27: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
! 28: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
! 29: */
! 30:
! 31: #include <sys/param.h>
! 32: #include <sys/systm.h>
! 33: #include <sys/namei.h>
! 34: #include <sys/proc.h>
! 35: #include <sys/filedesc.h>
! 36: #include <sys/ioctl.h>
! 37: #include <sys/mount.h>
! 38: #include <sys/kernel.h>
! 39: #include <sys/signal.h>
! 40: #include <sys/signalvar.h>
! 41: #include <sys/malloc.h>
! 42:
! 43: #include <sys/syscallargs.h>
! 44:
! 45: #include <compat/svr4/svr4_types.h>
! 46: #include <compat/svr4/svr4_signal.h>
! 47: #include <compat/svr4/svr4_syscallargs.h>
! 48: #include <compat/svr4/svr4_util.h>
! 49: #include <compat/svr4/svr4_ucontext.h>
! 50:
! 51: #define sigemptyset(s) bzero((s), sizeof(*(s)))
! 52: #define sigismember(s, n) (*(s) & sigmask(n))
! 53: #define sigaddset(s, n) (*(s) |= sigmask(n))
! 54:
! 55: #define svr4_sigmask(n) (1 << (((n) - 1) & (32 - 1)))
! 56: #define svr4_sigword(n) (((n) - 1) >> 5)
! 57: #define svr4_sigemptyset(s) bzero((s), sizeof(*(s)))
! 58: #define svr4_sigismember(s, n) ((s)->bits[svr4_sigword(n)] & svr4_sigmask(n))
! 59: #define svr4_sigaddset(s, n) ((s)->bits[svr4_sigword(n)] |= svr4_sigmask(n))
! 60:
! 61: static __inline void svr4_sigfillset(svr4_sigset_t *);
! 62: void svr4_to_bsd_sigaction(const struct svr4_sigaction *,
! 63: struct sigaction *);
! 64: void bsd_to_svr4_sigaction(const struct sigaction *,
! 65: struct svr4_sigaction *);
! 66:
! 67: static __inline void
! 68: svr4_sigfillset(s)
! 69: svr4_sigset_t *s;
! 70: {
! 71: int i;
! 72:
! 73: svr4_sigemptyset(s);
! 74: for (i = 1; i < SVR4_NSIG; i++)
! 75: svr4_sigaddset(s, i);
! 76: }
! 77:
! 78: int bsd_to_svr4_sig[] = {
! 79: 0,
! 80: SVR4_SIGHUP,
! 81: SVR4_SIGINT,
! 82: SVR4_SIGQUIT,
! 83: SVR4_SIGILL,
! 84: SVR4_SIGTRAP,
! 85: SVR4_SIGABRT,
! 86: SVR4_SIGEMT,
! 87: SVR4_SIGFPE,
! 88: SVR4_SIGKILL,
! 89: SVR4_SIGBUS,
! 90: SVR4_SIGSEGV,
! 91: SVR4_SIGSYS,
! 92: SVR4_SIGPIPE,
! 93: SVR4_SIGALRM,
! 94: SVR4_SIGTERM,
! 95: SVR4_SIGURG,
! 96: SVR4_SIGSTOP,
! 97: SVR4_SIGTSTP,
! 98: SVR4_SIGCONT,
! 99: SVR4_SIGCHLD,
! 100: SVR4_SIGTTIN,
! 101: SVR4_SIGTTOU,
! 102: SVR4_SIGIO,
! 103: SVR4_SIGXCPU,
! 104: SVR4_SIGXFSZ,
! 105: SVR4_SIGVTALRM,
! 106: SVR4_SIGPROF,
! 107: SVR4_SIGWINCH,
! 108: 0,
! 109: SVR4_SIGUSR1,
! 110: SVR4_SIGUSR2,
! 111: };
! 112:
! 113: int svr4_to_bsd_sig[] = {
! 114: 0,
! 115: SIGHUP,
! 116: SIGINT,
! 117: SIGQUIT,
! 118: SIGILL,
! 119: SIGTRAP,
! 120: SIGABRT,
! 121: SIGEMT,
! 122: SIGFPE,
! 123: SIGKILL,
! 124: SIGBUS,
! 125: SIGSEGV,
! 126: SIGSYS,
! 127: SIGPIPE,
! 128: SIGALRM,
! 129: SIGTERM,
! 130: SIGUSR1,
! 131: SIGUSR2,
! 132: SIGCHLD,
! 133: 0,
! 134: SIGWINCH,
! 135: SIGURG,
! 136: SIGIO,
! 137: SIGSTOP,
! 138: SIGTSTP,
! 139: SIGCONT,
! 140: SIGTTIN,
! 141: SIGTTOU,
! 142: SIGVTALRM,
! 143: SIGPROF,
! 144: SIGXCPU,
! 145: SIGXFSZ,
! 146: };
! 147:
! 148: void
! 149: svr4_to_bsd_sigset(sss, bss)
! 150: const svr4_sigset_t *sss;
! 151: sigset_t *bss;
! 152: {
! 153: int i, newsig;
! 154:
! 155: sigemptyset(bss);
! 156: for (i = 1; i < SVR4_NSIG; i++) {
! 157: if (svr4_sigismember(sss, i)) {
! 158: newsig = svr4_to_bsd_sig[i];
! 159: if (newsig)
! 160: sigaddset(bss, newsig);
! 161: }
! 162: }
! 163: }
! 164:
! 165:
! 166: void
! 167: bsd_to_svr4_sigset(bss, sss)
! 168: const sigset_t *bss;
! 169: svr4_sigset_t *sss;
! 170: {
! 171: int i, newsig;
! 172:
! 173: svr4_sigemptyset(sss);
! 174: for (i = 1; i < NSIG; i++) {
! 175: if (sigismember(bss, i)) {
! 176: newsig = bsd_to_svr4_sig[i];
! 177: if (newsig)
! 178: svr4_sigaddset(sss, newsig);
! 179: }
! 180: }
! 181: }
! 182:
! 183: /*
! 184: * XXX: Only a subset of the flags is currently implemented.
! 185: */
! 186: void
! 187: svr4_to_bsd_sigaction(ssa, bsa)
! 188: const struct svr4_sigaction *ssa;
! 189: struct sigaction *bsa;
! 190: {
! 191:
! 192: bsa->sa_handler = (sig_t) ssa->sa__handler;
! 193: svr4_to_bsd_sigset(&ssa->sa_mask, &bsa->sa_mask);
! 194: bsa->sa_flags = 0;
! 195: if ((ssa->sa_flags & SVR4_SA_ONSTACK) != 0)
! 196: bsa->sa_flags |= SA_ONSTACK;
! 197: if ((ssa->sa_flags & SVR4_SA_RESTART) != 0)
! 198: bsa->sa_flags |= SA_RESTART;
! 199: if ((ssa->sa_flags & SVR4_SA_RESETHAND) != 0)
! 200: bsa->sa_flags |= SA_RESETHAND;
! 201: if ((ssa->sa_flags & SVR4_SA_NOCLDSTOP) != 0)
! 202: bsa->sa_flags |= SA_NOCLDSTOP;
! 203: if ((ssa->sa_flags & SVR4_SA_NOCLDWAIT) != 0)
! 204: bsa->sa_flags |= SA_NOCLDWAIT;
! 205: if ((ssa->sa_flags & SVR4_SA_NODEFER) != 0)
! 206: bsa->sa_flags |= SA_NODEFER;
! 207: if ((ssa->sa_flags & SVR4_SA_SIGINFO) != 0)
! 208: bsa->sa_flags |= SA_SIGINFO;
! 209: }
! 210:
! 211: void
! 212: bsd_to_svr4_sigaction(bsa, ssa)
! 213: const struct sigaction *bsa;
! 214: struct svr4_sigaction *ssa;
! 215: {
! 216:
! 217: ssa->sa__handler = (svr4_sig_t) bsa->sa_handler;
! 218: bsd_to_svr4_sigset(&bsa->sa_mask, &ssa->sa_mask);
! 219: ssa->sa_flags = 0;
! 220: if ((bsa->sa_flags & SA_ONSTACK) != 0)
! 221: ssa->sa_flags |= SVR4_SA_ONSTACK;
! 222: if ((bsa->sa_flags & SA_RESETHAND) != 0)
! 223: ssa->sa_flags |= SVR4_SA_RESETHAND;
! 224: if ((bsa->sa_flags & SA_RESTART) != 0)
! 225: ssa->sa_flags |= SVR4_SA_RESTART;
! 226: if ((bsa->sa_flags & SA_NODEFER) != 0)
! 227: ssa->sa_flags |= SVR4_SA_NODEFER;
! 228: if ((bsa->sa_flags & SA_NOCLDSTOP) != 0)
! 229: ssa->sa_flags |= SVR4_SA_NOCLDSTOP;
! 230: if ((bsa->sa_flags & SA_NOCLDWAIT) != 0)
! 231: ssa->sa_flags |= SVR4_SA_NOCLDWAIT;
! 232: if ((bsa->sa_flags & SA_SIGINFO) != 0)
! 233: ssa->sa_flags |= SVR4_SA_SIGINFO;
! 234: }
! 235:
! 236: void
! 237: svr4_to_bsd_sigaltstack(sss, bss)
! 238: const struct svr4_sigaltstack *sss;
! 239: struct sigaltstack *bss;
! 240: {
! 241:
! 242: bss->ss_sp = sss->ss_sp;
! 243: bss->ss_size = sss->ss_size;
! 244: bss->ss_flags = 0;
! 245:
! 246: if ((sss->ss_flags & SVR4_SS_DISABLE) != 0)
! 247: bss->ss_flags |= SS_DISABLE;
! 248: if ((sss->ss_flags & SVR4_SS_ONSTACK) != 0)
! 249: bss->ss_flags |= SS_ONSTACK;
! 250: }
! 251:
! 252: void
! 253: bsd_to_svr4_sigaltstack(bss, sss)
! 254: const struct sigaltstack *bss;
! 255: struct svr4_sigaltstack *sss;
! 256: {
! 257:
! 258: sss->ss_sp = bss->ss_sp;
! 259: sss->ss_size = bss->ss_size;
! 260: sss->ss_flags = 0;
! 261:
! 262: if ((bss->ss_flags & SS_DISABLE) != 0)
! 263: sss->ss_flags |= SVR4_SS_DISABLE;
! 264: if ((bss->ss_flags & SS_ONSTACK) != 0)
! 265: sss->ss_flags |= SVR4_SS_ONSTACK;
! 266: }
! 267:
! 268: int
! 269: svr4_sys_sigaction(p, v, retval)
! 270: register struct proc *p;
! 271: void *v;
! 272: register_t *retval;
! 273: {
! 274: struct svr4_sys_sigaction_args /* {
! 275: syscallarg(int) signum;
! 276: syscallarg(struct svr4_sigaction *) nsa;
! 277: syscallarg(struct svr4_sigaction *) osa;
! 278: } */ *uap = v;
! 279: struct svr4_sigaction *nssa, *ossa, tmpssa;
! 280: struct sigaction *nbsa, *obsa, tmpbsa;
! 281: struct sys_sigaction_args sa;
! 282: caddr_t sg;
! 283: int error;
! 284:
! 285: if (SCARG(uap, signum) < 0 || SCARG(uap, signum) >= SVR4_NSIG)
! 286: return (EINVAL);
! 287:
! 288: sg = stackgap_init(p->p_emul);
! 289: nssa = SCARG(uap, nsa);
! 290: ossa = SCARG(uap, osa);
! 291:
! 292: if (ossa != NULL)
! 293: obsa = stackgap_alloc(&sg, sizeof(struct sigaction));
! 294: else
! 295: obsa = NULL;
! 296:
! 297: if (nssa != NULL) {
! 298: nbsa = stackgap_alloc(&sg, sizeof(struct sigaction));
! 299: if ((error = copyin(nssa, &tmpssa, sizeof(tmpssa))) != 0)
! 300: return error;
! 301: svr4_to_bsd_sigaction(&tmpssa, &tmpbsa);
! 302: if ((error = copyout(&tmpbsa, nbsa, sizeof(tmpbsa))) != 0)
! 303: return error;
! 304: } else
! 305: nbsa = NULL;
! 306:
! 307: SCARG(&sa, signum) = svr4_to_bsd_sig[SCARG(uap, signum)];
! 308: SCARG(&sa, nsa) = nbsa;
! 309: SCARG(&sa, osa) = obsa;
! 310:
! 311: if ((error = sys_sigaction(p, &sa, retval)) != 0)
! 312: return error;
! 313:
! 314: if (ossa != NULL) {
! 315: if ((error = copyin(obsa, &tmpbsa, sizeof(tmpbsa))) != 0)
! 316: return error;
! 317: bsd_to_svr4_sigaction(&tmpbsa, &tmpssa);
! 318: if ((error = copyout(&tmpssa, ossa, sizeof(tmpssa))) != 0)
! 319: return error;
! 320: }
! 321:
! 322: return 0;
! 323: }
! 324:
! 325: int
! 326: svr4_sys_sigaltstack(p, v, retval)
! 327: register struct proc *p;
! 328: void *v;
! 329: register_t *retval;
! 330: {
! 331: struct svr4_sys_sigaltstack_args /* {
! 332: syscallarg(struct svr4_sigaltstack *) nss;
! 333: syscallarg(struct svr4_sigaltstack *) oss;
! 334: } */ *uap = v;
! 335: struct svr4_sigaltstack *nsss, *osss, tmpsss;
! 336: struct sigaltstack *nbss, *obss, tmpbss;
! 337: struct sys_sigaltstack_args sa;
! 338: caddr_t sg;
! 339: int error;
! 340:
! 341: sg = stackgap_init(p->p_emul);
! 342: nsss = SCARG(uap, nss);
! 343: osss = SCARG(uap, oss);
! 344:
! 345: if (osss != NULL)
! 346: obss = stackgap_alloc(&sg, sizeof(struct sigaltstack));
! 347: else
! 348: obss = NULL;
! 349:
! 350: if (nsss != NULL) {
! 351: nbss = stackgap_alloc(&sg, sizeof(struct sigaltstack));
! 352: if ((error = copyin(nsss, &tmpsss, sizeof(tmpsss))) != 0)
! 353: return error;
! 354: svr4_to_bsd_sigaltstack(&tmpsss, &tmpbss);
! 355: if ((error = copyout(&tmpbss, nbss, sizeof(tmpbss))) != 0)
! 356: return error;
! 357: } else
! 358: nbss = NULL;
! 359:
! 360: SCARG(&sa, nss) = nbss;
! 361: SCARG(&sa, oss) = obss;
! 362:
! 363: if ((error = sys_sigaltstack(p, &sa, retval)) != 0)
! 364: return error;
! 365:
! 366: if (obss != NULL) {
! 367: if ((error = copyin(obss, &tmpbss, sizeof(tmpbss))) != 0)
! 368: return error;
! 369: bsd_to_svr4_sigaltstack(&tmpbss, &tmpsss);
! 370: if ((error = copyout(&tmpsss, osss, sizeof(tmpsss))) != 0)
! 371: return error;
! 372: }
! 373:
! 374: return 0;
! 375: }
! 376:
! 377: /*
! 378: * Stolen from the ibcs2 one
! 379: */
! 380: int
! 381: svr4_sys_signal(p, v, retval)
! 382: register struct proc *p;
! 383: void *v;
! 384: register_t *retval;
! 385: {
! 386: struct svr4_sys_signal_args /* {
! 387: syscallarg(int) signum;
! 388: syscallarg(svr4_sig_t) handler;
! 389: } */ *uap = v;
! 390: int signum, error;
! 391: caddr_t sg = stackgap_init(p->p_emul);
! 392:
! 393: signum = SVR4_SIGNO(SCARG(uap, signum));
! 394: if (signum < 0 || signum >= SVR4_NSIG) {
! 395: if (SVR4_SIGCALL(SCARG(uap, signum)) == SVR4_SIGNAL_MASK ||
! 396: SVR4_SIGCALL(SCARG(uap, signum)) == SVR4_SIGDEFER_MASK)
! 397: *retval = (int)SVR4_SIG_ERR;
! 398: return EINVAL;
! 399: }
! 400: signum = svr4_to_bsd_sig[signum];
! 401:
! 402: switch (SVR4_SIGCALL(SCARG(uap, signum))) {
! 403: case SVR4_SIGDEFER_MASK:
! 404: /*
! 405: * sigset is identical to signal() except
! 406: * that SIG_HOLD is allowed as
! 407: * an action.
! 408: */
! 409: if (SCARG(uap, handler) == SVR4_SIG_HOLD) {
! 410: struct sys_sigprocmask_args sa;
! 411:
! 412: SCARG(&sa, how) = SIG_BLOCK;
! 413: SCARG(&sa, mask) = sigmask(signum);
! 414: return sys_sigprocmask(p, &sa, retval);
! 415: }
! 416: /* FALLTHROUGH */
! 417:
! 418: case SVR4_SIGNAL_MASK:
! 419: {
! 420: struct sys_sigaction_args sa_args;
! 421: struct sigaction *nbsa, *obsa, sa;
! 422:
! 423: nbsa = stackgap_alloc(&sg, sizeof(struct sigaction));
! 424: obsa = stackgap_alloc(&sg, sizeof(struct sigaction));
! 425: SCARG(&sa_args, signum) = signum;
! 426: SCARG(&sa_args, nsa) = nbsa;
! 427: SCARG(&sa_args, osa) = obsa;
! 428:
! 429: sa.sa_handler = (sig_t) SCARG(uap, handler);
! 430: sigemptyset(&sa.sa_mask);
! 431: sa.sa_flags = 0;
! 432: #if 0
! 433: if (signum != SIGALRM)
! 434: sa.sa_flags = SA_RESTART;
! 435: #endif
! 436: if ((error = copyout(&sa, nbsa, sizeof(sa))) != 0)
! 437: return error;
! 438: if ((error = sys_sigaction(p, &sa_args, retval)) != 0) {
! 439: DPRINTF(("signal: sigaction failed: %d\n",
! 440: error));
! 441: *retval = (int)SVR4_SIG_ERR;
! 442: return error;
! 443: }
! 444: if ((error = copyin(obsa, &sa, sizeof(sa))) != 0)
! 445: return error;
! 446: *retval = (int)sa.sa_handler;
! 447: return 0;
! 448: }
! 449:
! 450: case SVR4_SIGHOLD_MASK:
! 451: {
! 452: struct sys_sigprocmask_args sa;
! 453:
! 454: SCARG(&sa, how) = SIG_BLOCK;
! 455: SCARG(&sa, mask) = sigmask(signum);
! 456: return sys_sigprocmask(p, &sa, retval);
! 457: }
! 458:
! 459: case SVR4_SIGRELSE_MASK:
! 460: {
! 461: struct sys_sigprocmask_args sa;
! 462:
! 463: SCARG(&sa, how) = SIG_UNBLOCK;
! 464: SCARG(&sa, mask) = sigmask(signum);
! 465: return sys_sigprocmask(p, &sa, retval);
! 466: }
! 467:
! 468: case SVR4_SIGIGNORE_MASK:
! 469: {
! 470: struct sys_sigaction_args sa_args;
! 471: struct sigaction *bsa, sa;
! 472:
! 473: bsa = stackgap_alloc(&sg, sizeof(struct sigaction));
! 474: SCARG(&sa_args, signum) = signum;
! 475: SCARG(&sa_args, nsa) = bsa;
! 476: SCARG(&sa_args, osa) = NULL;
! 477:
! 478: sa.sa_handler = SIG_IGN;
! 479: sigemptyset(&sa.sa_mask);
! 480: sa.sa_flags = 0;
! 481: if ((error = copyout(&sa, bsa, sizeof(sa))) != 0)
! 482: return error;
! 483: if ((error = sys_sigaction(p, &sa_args, retval)) != 0) {
! 484: DPRINTF(("sigignore: sigaction failed\n"));
! 485: return error;
! 486: }
! 487: return 0;
! 488: }
! 489:
! 490: case SVR4_SIGPAUSE_MASK:
! 491: {
! 492: struct sys_sigsuspend_args sa;
! 493:
! 494: SCARG(&sa, mask) = p->p_sigmask & ~sigmask(signum);
! 495: return sys_sigsuspend(p, &sa, retval);
! 496: }
! 497:
! 498: default:
! 499: return ENOSYS;
! 500: }
! 501: }
! 502:
! 503: int
! 504: svr4_sys_sigprocmask(p, v, retval)
! 505: register struct proc *p;
! 506: void *v;
! 507: register_t *retval;
! 508: {
! 509: struct svr4_sys_sigprocmask_args /* {
! 510: syscallarg(int) how;
! 511: syscallarg(svr4_sigset_t *) set;
! 512: syscallarg(svr4_sigset_t *) oset;
! 513: } */ *uap = v;
! 514: svr4_sigset_t sss;
! 515: sigset_t bss;
! 516: int error = 0;
! 517:
! 518: if (SCARG(uap, oset) != NULL) {
! 519: /* Fix the return value first if needed */
! 520: bsd_to_svr4_sigset(&p->p_sigmask, &sss);
! 521: if ((error = copyout(&sss, SCARG(uap, oset), sizeof(sss))) != 0)
! 522: return error;
! 523: }
! 524:
! 525: if (SCARG(uap, set) == NULL)
! 526: /* Just examine */
! 527: return 0;
! 528:
! 529: if ((error = copyin(SCARG(uap, set), &sss, sizeof(sss))) != 0)
! 530: return error;
! 531:
! 532: svr4_to_bsd_sigset(&sss, &bss);
! 533:
! 534: (void) splhigh();
! 535:
! 536: switch (SCARG(uap, how)) {
! 537: case SVR4_SIG_BLOCK:
! 538: p->p_sigmask |= bss & ~sigcantmask;
! 539: break;
! 540:
! 541: case SVR4_SIG_UNBLOCK:
! 542: p->p_sigmask &= ~bss;
! 543: break;
! 544:
! 545: case SVR4_SIG_SETMASK:
! 546: p->p_sigmask = bss & ~sigcantmask;
! 547: break;
! 548:
! 549: default:
! 550: error = EINVAL;
! 551: break;
! 552: }
! 553:
! 554: (void) spl0();
! 555:
! 556: return error;
! 557: }
! 558:
! 559: int
! 560: svr4_sys_sigpending(p, v, retval)
! 561: register struct proc *p;
! 562: void *v;
! 563: register_t *retval;
! 564: {
! 565: struct svr4_sys_sigpending_args /* {
! 566: syscallarg(int) what;
! 567: syscallarg(svr4_sigset_t *) mask;
! 568: } */ *uap = v;
! 569: sigset_t bss;
! 570: svr4_sigset_t sss;
! 571:
! 572: switch (SCARG(uap, what)) {
! 573: case 1: /* sigpending */
! 574: if (SCARG(uap, mask) == NULL)
! 575: return 0;
! 576: bss = p->p_siglist & p->p_sigmask;
! 577: bsd_to_svr4_sigset(&bss, &sss);
! 578: break;
! 579:
! 580: case 2: /* sigfillset */
! 581: svr4_sigfillset(&sss);
! 582: break;
! 583:
! 584: default:
! 585: return EINVAL;
! 586: }
! 587:
! 588: return copyout(&sss, SCARG(uap, mask), sizeof(sss));
! 589: }
! 590:
! 591: int
! 592: svr4_sys_sigsuspend(p, v, retval)
! 593: register struct proc *p;
! 594: void *v;
! 595: register_t *retval;
! 596: {
! 597: struct svr4_sys_sigsuspend_args /* {
! 598: syscallarg(svr4_sigset_t *) ss;
! 599: } */ *uap = v;
! 600: svr4_sigset_t sss;
! 601: sigset_t bss;
! 602: struct sys_sigsuspend_args sa;
! 603: int error;
! 604:
! 605: if ((error = copyin(SCARG(uap, ss), &sss, sizeof(sss))) != 0)
! 606: return error;
! 607:
! 608: svr4_to_bsd_sigset(&sss, &bss);
! 609:
! 610: SCARG(&sa, mask) = bss;
! 611: return sys_sigsuspend(p, &sa, retval);
! 612: }
! 613:
! 614: int
! 615: svr4_sys_kill(p, v, retval)
! 616: register struct proc *p;
! 617: void *v;
! 618: register_t *retval;
! 619: {
! 620: struct svr4_sys_kill_args /* {
! 621: syscallarg(int) pid;
! 622: syscallarg(int) signum;
! 623: } */ *uap = v;
! 624: struct sys_kill_args ka;
! 625:
! 626: if (SCARG(uap, signum) < 0 || SCARG(uap, signum) >= SVR4_NSIG)
! 627: return (EINVAL);
! 628: SCARG(&ka, pid) = SCARG(uap, pid);
! 629: SCARG(&ka, signum) = svr4_to_bsd_sig[SCARG(uap, signum)];
! 630: return sys_kill(p, &ka, retval);
! 631: }
! 632:
! 633: int
! 634: svr4_sys_context(p, v, retval)
! 635: register struct proc *p;
! 636: void *v;
! 637: register_t *retval;
! 638: {
! 639: struct svr4_sys_context_args /* {
! 640: syscallarg(int) func;
! 641: syscallarg(struct svr4_ucontext *) uc;
! 642: } */ *uap = v;
! 643: struct svr4_ucontext uc;
! 644: int error;
! 645: *retval = 0;
! 646:
! 647: switch (SCARG(uap, func)) {
! 648: case 0:
! 649: DPRINTF(("getcontext(%p)\n", SCARG(uap, uc)));
! 650: svr4_getcontext(p, &uc, p->p_sigmask,
! 651: p->p_sigacts->ps_sigstk.ss_flags & SS_ONSTACK);
! 652: return copyout(&uc, SCARG(uap, uc), sizeof(uc));
! 653:
! 654: case 1:
! 655: DPRINTF(("setcontext(%p)\n", SCARG(uap, uc)));
! 656: if ((error = copyin(SCARG(uap, uc), &uc, sizeof(uc))) != 0)
! 657: return error;
! 658: return svr4_setcontext(p, &uc);
! 659:
! 660: default:
! 661: DPRINTF(("context(%d, %p)\n", SCARG(uap, func),
! 662: SCARG(uap, uc)));
! 663: return ENOSYS;
! 664: }
! 665: return 0;
! 666: }
! 667:
! 668: int
! 669: svr4_sys_pause(p, v, retval)
! 670: register struct proc *p;
! 671: void *v;
! 672: register_t *retval;
! 673: {
! 674: struct sys_sigsuspend_args bsa;
! 675:
! 676: SCARG(&bsa, mask) = p->p_sigmask;
! 677: return sys_sigsuspend(p, &bsa, retval);
! 678: }
CVSweb