[BACK]Return to signals.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / rump / librump / rumpkern

Annotation of src/sys/rump/librump/rumpkern/signals.c, Revision 1.2

1.2     ! pooka       1: /*     $NetBSD: signals.c,v 1.1 2010/04/21 11:38:05 pooka Exp $        */
1.1       pooka       2:
                      3: /*
                      4:  * Copyright (c) 2010 Antti Kantee.  All Rights Reserved.
                      5:  *
                      6:  * Redistribution and use in source and binary forms, with or without
                      7:  * modification, are permitted provided that the following conditions
                      8:  * are met:
                      9:  * 1. Redistributions of source code must retain the above copyright
                     10:  *    notice, this list of conditions and the following disclaimer.
                     11:  * 2. Redistributions in binary form must reproduce the above copyright
                     12:  *    notice, this list of conditions and the following disclaimer in the
                     13:  *    documentation and/or other materials provided with the distribution.
                     14:  *
                     15:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
                     16:  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
                     17:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
                     18:  * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
                     19:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     20:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
                     21:  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     22:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     23:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     24:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     25:  * SUCH DAMAGE.
                     26:  */
                     27:
                     28: #include <sys/cdefs.h>
1.2     ! pooka      29: __KERNEL_RCSID(0, "$NetBSD: signals.c,v 1.1 2010/04/21 11:38:05 pooka Exp $");
1.1       pooka      30:
                     31: #include <sys/param.h>
                     32: #include <sys/atomic.h>
                     33: #include <sys/event.h>
                     34: #include <sys/proc.h>
                     35: #include <sys/signal.h>
                     36:
                     37: #include <rump/rump.h>
                     38: #include <rump/rumpuser.h>
                     39:
                     40: #include "rumpkern_if_priv.h"
                     41:
                     42: const struct filterops sig_filtops;
1.2     ! pooka      43: sigset_t sigcantmask;
1.1       pooka      44:
                     45: /* RUMP_SIGMODEL_PANIC */
                     46:
                     47: static void
                     48: rumpsig_panic(pid_t target, int signo)
                     49: {
                     50:
                     51:        switch (signo) {
                     52:        case SIGSYS:
                     53:                break;
                     54:        default:
                     55:                panic("unhandled signal %d", signo);
                     56:        }
                     57: }
                     58:
                     59: /* RUMP_SIGMODEL_IGNORE */
                     60:
                     61: static void
                     62: rumpsig_ignore(pid_t target, int signo)
                     63: {
                     64:
                     65:        return;
                     66: }
                     67:
                     68: /* RUMP_SIGMODEL_HOST */
                     69:
                     70: static void
                     71: rumpsig_host(pid_t target, int signo)
                     72: {
                     73:        int error;
                     74:
                     75:        rumpuser_kill(target, signo, &error);
                     76: }
                     77:
                     78: /* RUMP_SIGMODEL_RAISE */
                     79:
                     80: static void
                     81: rumpsig_raise(pid_t target, int signo)
                     82: {
                     83:        int error;
                     84:
                     85:        rumpuser_kill(RUMPUSER_PID_SELF, signo, &error);
                     86: }
                     87:
                     88: typedef void (*rumpsig_fn)(pid_t pid, int sig);
                     89:
                     90: rumpsig_fn rumpsig = rumpsig_panic;
                     91:
                     92: /*
                     93:  * Set signal delivery model.  It would be nice if we could
                     94:  * take a functional argument.  But then we'd need some
                     95:  * OS independent way to represent a signal number and also
                     96:  * a method for easy processing (parsing is boring).
                     97:  *
                     98:  * Plus, upcalls from the rump kernel into process space except
                     99:  * via rumpuser is a somewhat gray area now.
                    100:  */
                    101: void
                    102: rump_boot_setsigmodel(enum rump_sigmodel model)
                    103: {
                    104:
                    105:        switch (model) {
                    106:        case RUMP_SIGMODEL_PANIC:
                    107:                atomic_swap_ptr(&rumpsig, rumpsig_panic);
                    108:                break;
                    109:        case RUMP_SIGMODEL_IGNORE:
                    110:                atomic_swap_ptr(&rumpsig, rumpsig_ignore);
                    111:                break;
                    112:        case RUMP_SIGMODEL_HOST:
                    113:                atomic_swap_ptr(&rumpsig, rumpsig_host);
                    114:                break;
                    115:        case RUMP_SIGMODEL_RAISE:
                    116:                atomic_swap_ptr(&rumpsig, rumpsig_raise);
                    117:                break;
                    118:        }
                    119: }
                    120:
                    121: void
                    122: psignal(struct proc *p, int sig)
                    123: {
                    124:
                    125:        rumpsig(p->p_pid, sig);
                    126: }
                    127:
                    128: void
                    129: pgsignal(struct pgrp *pgrp, int sig, int checktty)
                    130: {
                    131:
                    132:        rumpsig(-pgrp->pg_id, sig);
                    133: }
                    134:
                    135: void
                    136: kpsignal(struct proc *p, ksiginfo_t *ksi, void *data)
                    137: {
                    138:
                    139:        rumpsig(p->p_pid, ksi->ksi_signo);
                    140: }
                    141:
                    142: void
                    143: kpgsignal(struct pgrp *pgrp, ksiginfo_t *ksi, void *data, int checkctty)
                    144: {
                    145:
                    146:        rumpsig(-pgrp->pg_id, ksi->ksi_signo);
                    147: }
                    148:
                    149: int
                    150: sigispending(struct lwp *l, int signo)
                    151: {
                    152:
                    153:        return 0;
                    154: }
                    155:
                    156: void
                    157: sigpending1(struct lwp *l, sigset_t *ss)
                    158: {
                    159:
                    160:        sigemptyset(ss);
                    161: }
                    162:
                    163: int
                    164: sigismasked(struct lwp *l, int sig)
                    165: {
                    166:
                    167:        return 0;
                    168: }
                    169:
                    170: void
                    171: sigclearall(struct proc *p, const sigset_t *mask, ksiginfoq_t *kq)
                    172: {
                    173:
                    174:        /* nada */
                    175: }
                    176:
                    177: void
                    178: ksiginfo_queue_drain0(ksiginfoq_t *kq)
                    179: {
                    180:
                    181:        if (!(CIRCLEQ_EMPTY(kq)))
                    182:                panic("how did that get there?");
                    183: }

CVSweb <webmaster@jp.NetBSD.org>