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

Cache object: 7c95df733aa8bca941e8056062dc1113


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