The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/emulation/43bsd/43bsd_signal.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * 43BSD_SIGNAL.C       - 4.3BSD compatibility signal syscalls
    3  *
    4  * Copyright (c) 1989, 1993
    5  *      The Regents of the University of California.  All rights reserved.
    6  * (c) UNIX System Laboratories, Inc.
    7  * All or some portions of this file are derived from material licensed
    8  * to the University of California by American Telephone and Telegraph
    9  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
   10  * the permission of UNIX System Laboratories, Inc.
   11  *
   12  * Redistribution and use in source and binary forms, with or without
   13  * modification, are permitted provided that the following conditions
   14  * are met:
   15  * 1. Redistributions of source code must retain the above copyright
   16  *    notice, this list of conditions and the following disclaimer.
   17  * 2. Redistributions in binary form must reproduce the above copyright
   18  *    notice, this list of conditions and the following disclaimer in the
   19  *    documentation and/or other materials provided with the distribution.
   20  * 3. Neither the name of the University nor the names of its contributors
   21  *    may be used to endorse or promote products derived from this software
   22  *    without specific prior written permission.
   23  *
   24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   34  * SUCH DAMAGE.
   35  *
   36  * $DragonFly: src/sys/emulation/43bsd/43bsd_signal.c,v 1.5 2007/03/12 21:07:42 corecode Exp $
   37  *      from: DragonFly kern/kern_sig.c,v 1.22
   38  *
   39  * These syscalls used to live in kern/kern_sig.c.  They are modified
   40  * to use the new split syscalls.
   41  */
   42 
   43 #include "opt_compat.h"
   44 
   45 #include <sys/param.h>
   46 #include <sys/systm.h>
   47 #include <sys/sysproto.h>
   48 #include <sys/conf.h>
   49 #include <sys/kernel.h>
   50 #include <sys/kern_syscall.h>
   51 #include <sys/proc.h>
   52 #include <sys/signal.h>
   53 #include <sys/signalvar.h>
   54 
   55 #include <sys/thread2.h>
   56 
   57 #define ONSIG   32              /* NSIG for osig* syscalls.  XXX. */
   58 
   59 #define SIG2OSIG(sig, osig)     osig = (sig).__bits[0]
   60 #define OSIG2SIG(osig, sig)     SIGEMPTYSET(sig); (sig).__bits[0] = osig
   61 
   62 #define SIGSETLO(set1, set2)    ((set1).__bits[0] = (set2).__bits[0])
   63 
   64 /*
   65  * These syscalls are unncessary because it is next to impossible to
   66  * find 4.3BSD binaries built for i386.  The current libc has routines
   67  * which fake the 4.3BSD family of signal syscalls, so anything built
   68  * from source won't be using these.
   69  *
   70  * This file is provided for educational purposes only.  The osigvec()
   71  * syscall is probably broken because the current signal code uses
   72  * a different signal trampoline.
   73  *
   74  * MPALMOSTSAFE
   75  */
   76 int
   77 sys_osigvec(struct osigvec_args *uap)
   78 {
   79         struct sigvec vec;
   80         struct sigaction nsa, osa;
   81         struct sigaction *nsap, *osap;
   82         int error;
   83 
   84         if (uap->signum <= 0 || uap->signum >= ONSIG)
   85                 return (EINVAL);
   86         nsap = (uap->nsv != NULL) ? &nsa : NULL;
   87         osap = (uap->osv != NULL) ? &osa : NULL;
   88         if (nsap) {
   89                 error = copyin(uap->nsv, &vec, sizeof(vec));
   90                 if (error)
   91                         return (error);
   92                 nsap->sa_handler = vec.sv_handler;
   93                 OSIG2SIG(vec.sv_mask, nsap->sa_mask);
   94                 nsap->sa_flags = vec.sv_flags;
   95                 nsap->sa_flags ^= SA_RESTART;   /* opposite of SV_INTERRUPT */
   96         }
   97 
   98         error = kern_sigaction(uap->signum, nsap, osap);
   99 
  100         if (osap && !error) {
  101                 vec.sv_handler = osap->sa_handler;
  102                 SIG2OSIG(osap->sa_mask, vec.sv_mask);
  103                 vec.sv_flags = osap->sa_flags;
  104                 vec.sv_flags &= ~SA_NOCLDWAIT;
  105                 vec.sv_flags ^= SA_RESTART;
  106                 error = copyout(&vec, uap->osv, sizeof(vec));
  107         }
  108         return (error);
  109 }
  110 
  111 /*
  112  * MPSAFE
  113  */
  114 int
  115 sys_osigblock(struct osigblock_args *uap)
  116 {
  117         struct lwp *lp = curthread->td_lwp;
  118         sigset_t set;
  119 
  120         OSIG2SIG(uap->mask, set);
  121         SIG_CANTMASK(set);
  122         crit_enter();
  123         SIG2OSIG(lp->lwp_sigmask, uap->sysmsg_iresult);
  124         SIGSETOR(lp->lwp_sigmask, set);
  125         crit_exit();
  126         return (0);
  127 }
  128 
  129 /*
  130  * MPSAFE
  131  */
  132 int
  133 sys_osigsetmask(struct osigsetmask_args *uap)
  134 {
  135         struct lwp *lp = curthread->td_lwp;
  136         sigset_t set;
  137 
  138         OSIG2SIG(uap->mask, set);
  139         SIG_CANTMASK(set);
  140         crit_enter();
  141         SIG2OSIG(lp->lwp_sigmask, uap->sysmsg_iresult);
  142         SIGSETLO(lp->lwp_sigmask, set);
  143         crit_exit();
  144         return (0);
  145 }
  146 
  147 /*
  148  * MPSAFE
  149  */
  150 int
  151 sys_osigstack(struct osigstack_args *uap)
  152 {
  153         struct lwp *lp = curthread->td_lwp;
  154         struct sigstack ss;
  155         int error = 0;
  156 
  157         ss.ss_sp = lp->lwp_sigstk.ss_sp;
  158         ss.ss_onstack = lp->lwp_sigstk.ss_flags & SS_ONSTACK;
  159         if (uap->oss && (error = copyout(&ss, uap->oss,
  160                                          sizeof(struct sigstack)))) {
  161                 return (error);
  162         }
  163         if (uap->nss && (error = copyin(uap->nss, &ss, sizeof(ss))) == 0) {
  164                 lp->lwp_sigstk.ss_sp = ss.ss_sp;
  165                 lp->lwp_sigstk.ss_size = 0;
  166                 lp->lwp_sigstk.ss_flags |= ss.ss_onstack & SS_ONSTACK;
  167                 lp->lwp_flags |= LWP_ALTSTACK;
  168         }
  169         return (error);
  170 }
  171 
  172 int
  173 sys_okillpg(struct okillpg_args *uap)
  174 {
  175         int error;
  176 
  177         error = kern_kill(uap->signum, -uap->pgid, -1);
  178 
  179         return (error);
  180 }

Cache object: ee7be94f09e592e21a48d371bdcabc7c


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.