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/svr4/svr4_signal.c

Version: -  FREEBSD  -  FREEBSD11  -  FREEBSD10  -  FREEBSD9  -  FREEBSD92  -  FREEBSD91  -  FREEBSD90  -  FREEBSD8  -  FREEBSD82  -  FREEBSD81  -  FREEBSD80  -  FREEBSD7  -  FREEBSD74  -  FREEBSD73  -  FREEBSD72  -  FREEBSD71  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

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

Cache object: c66eefb04e9e6765f9d5f7d24ab1034f


[ 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.