[BACK]Return to kern_sig.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / kern

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/kern/kern_sig.c between version 1.254.6.4 and 1.254.6.5

version 1.254.6.4, 2007/10/26 15:48:35 version 1.254.6.5, 2007/11/27 19:38:04
Line 204  sigacts_poolpage_free(struct pool *pp, v
Line 204  sigacts_poolpage_free(struct pool *pp, v
 struct sigacts *  struct sigacts *
 sigactsinit(struct proc *pp, int share)  sigactsinit(struct proc *pp, int share)
 {  {
         struct sigacts *ps;          struct sigacts *ps, *ps2;
   
         if (pp != NULL) {          ps = pp->p_sigacts;
                 KASSERT(mutex_owned(&pp->p_smutex));  
         }  
   
         if (share) {          if (share) {
                 ps = pp->p_sigacts;  
                 mutex_enter(&ps->sa_mutex);                  mutex_enter(&ps->sa_mutex);
                 ps->sa_refcnt++;                  ps->sa_refcnt++;
                 mutex_exit(&ps->sa_mutex);                  mutex_exit(&ps->sa_mutex);
                   ps2 = ps;
         } else {          } else {
                 if (pp)                  ps2 = pool_get(&sigacts_pool, PR_WAITOK);
                         mutex_exit(&pp->p_smutex);                  mutex_init(&ps2->sa_mutex, MUTEX_SPIN, IPL_SCHED);
                 ps = pool_get(&sigacts_pool, PR_WAITOK);                  mutex_enter(&ps->sa_mutex);
                 mutex_init(&ps->sa_mutex, MUTEX_SPIN, IPL_NONE);                  memcpy(&ps2->sa_sigdesc, ps->sa_sigdesc,
                 if (pp) {                      sizeof(ps2->sa_sigdesc));
                         mutex_enter(&pp->p_smutex);                  mutex_exit(&ps->sa_mutex);
                         memcpy(&ps->sa_sigdesc, pp->p_sigacts->sa_sigdesc,                  ps2->sa_refcnt = 1;
                             sizeof(ps->sa_sigdesc));  
                 } else  
                         memset(&ps->sa_sigdesc, 0, sizeof(ps->sa_sigdesc));  
                 ps->sa_refcnt = 1;  
         }          }
   
         return ps;          return ps2;
 }  }
   
 /*  /*
Line 242  void
Line 236  void
 sigactsunshare(struct proc *p)  sigactsunshare(struct proc *p)
 {  {
         struct sigacts *ps, *oldps;          struct sigacts *ps, *oldps;
         int refcnt;  
   
         KASSERT(mutex_owned(&p->p_smutex));  
   
         oldps = p->p_sigacts;          oldps = p->p_sigacts;
           if (oldps->sa_refcnt == 1)
         mutex_enter(&oldps->sa_mutex);  
         refcnt = oldps->sa_refcnt;  
         mutex_exit(&oldps->sa_mutex);  
         if (refcnt == 1)  
                 return;                  return;
           ps = pool_get(&sigacts_pool, PR_WAITOK);
         mutex_exit(&p->p_smutex);          mutex_init(&ps->sa_mutex, MUTEX_SPIN, IPL_SCHED);
         ps = sigactsinit(NULL, 0);          memset(&ps->sa_sigdesc, 0, sizeof(ps->sa_sigdesc));
         mutex_enter(&p->p_smutex);  
         p->p_sigacts = ps;          p->p_sigacts = ps;
   
         sigactsfree(oldps);          sigactsfree(oldps);
 }  }
   
Line 350  execsigs(struct proc *p)
Line 335  execsigs(struct proc *p)
   
         KASSERT(p->p_nlwps == 1);          KASSERT(p->p_nlwps == 1);
   
         mutex_enter(&p->p_smutex);  
   
         sigactsunshare(p);          sigactsunshare(p);
   
         ps = p->p_sigacts;          ps = p->p_sigacts;
   
         /*          /*
          * Reset caught signals.  Held signals remain held through           * Reset caught signals.  Held signals remain held through
          * l->l_sigmask (unless they were caught, and are now ignored           * l->l_sigmask (unless they were caught, and are now ignored
          * by default).           * by default).
            *
            * No need to lock yet, the process has only one LWP and
            * at this point the sigacts are private to the process.
          */           */
         sigemptyset(&tset);          sigemptyset(&tset);
         for (signo = 1; signo < NSIG; signo++) {          for (signo = 1; signo < NSIG; signo++) {
Line 377  execsigs(struct proc *p)
Line 362  execsigs(struct proc *p)
                 SIGACTION_PS(ps, signo).sa_flags = SA_RESTART;                  SIGACTION_PS(ps, signo).sa_flags = SA_RESTART;
         }          }
         ksiginfo_queue_init(&kq);          ksiginfo_queue_init(&kq);
   
           mutex_enter(&p->p_smutex);
         sigclearall(p, &tset, &kq);          sigclearall(p, &tset, &kq);
         sigemptyset(&p->p_sigctx.ps_sigcatch);          sigemptyset(&p->p_sigctx.ps_sigcatch);
   
Line 397  execsigs(struct proc *p)
Line 384  execsigs(struct proc *p)
         l->l_sigstk.ss_sp = 0;          l->l_sigstk.ss_sp = 0;
         ksiginfo_queue_init(&l->l_sigpend.sp_info);          ksiginfo_queue_init(&l->l_sigpend.sp_info);
         sigemptyset(&l->l_sigpend.sp_set);          sigemptyset(&l->l_sigpend.sp_set);
   
         mutex_exit(&p->p_smutex);          mutex_exit(&p->p_smutex);
   
         ksiginfo_queue_drain(&kq);          ksiginfo_queue_drain(&kq);
 }  }
   
Line 1208  void
Line 1195  void
 kpsignal2(struct proc *p, ksiginfo_t *ksi)  kpsignal2(struct proc *p, ksiginfo_t *ksi)
 {  {
         int prop, lid, toall, signo = ksi->ksi_signo;          int prop, lid, toall, signo = ksi->ksi_signo;
           struct sigacts *sa;
         struct lwp *l;          struct lwp *l;
         ksiginfo_t *kp;          ksiginfo_t *kp;
         ksiginfoq_t kq;          ksiginfoq_t kq;
Line 1264  kpsignal2(struct proc *p, ksiginfo_t *ks
Line 1252  kpsignal2(struct proc *p, ksiginfo_t *ks
                  * process dumps core immediately.                   * process dumps core immediately.
                  */                   */
                 if (KSI_TRAP_P(ksi)) {                  if (KSI_TRAP_P(ksi)) {
                           sa = p->p_sigacts;
                           mutex_enter(&sa->sa_mutex);
                         if (!sigismember(&p->p_sigctx.ps_sigcatch, signo)) {                          if (!sigismember(&p->p_sigctx.ps_sigcatch, signo)) {
                                 sigdelset(&p->p_sigctx.ps_sigignore, signo);                                  sigdelset(&p->p_sigctx.ps_sigignore, signo);
                                 SIGACTION(p, signo).sa_handler = SIG_DFL;                                  SIGACTION(p, signo).sa_handler = SIG_DFL;
                         }                          }
                           mutex_exit(&sa->sa_mutex);
                 }                  }
   
                 /*                  /*
Line 1857  sendsig_reset(struct lwp *l, int signo)
Line 1848  sendsig_reset(struct lwp *l, int signo)
         p->p_sigctx.ps_code = 0;          p->p_sigctx.ps_code = 0;
         p->p_sigctx.ps_signo = 0;          p->p_sigctx.ps_signo = 0;
   
           mutex_enter(&ps->sa_mutex);
         sigplusset(&SIGACTION_PS(ps, signo).sa_mask, &l->l_sigmask);          sigplusset(&SIGACTION_PS(ps, signo).sa_mask, &l->l_sigmask);
         if (SIGACTION_PS(ps, signo).sa_flags & SA_RESETHAND) {          if (SIGACTION_PS(ps, signo).sa_flags & SA_RESETHAND) {
                 sigdelset(&p->p_sigctx.ps_sigcatch, signo);                  sigdelset(&p->p_sigctx.ps_sigcatch, signo);
Line 1864  sendsig_reset(struct lwp *l, int signo)
Line 1856  sendsig_reset(struct lwp *l, int signo)
                         sigaddset(&p->p_sigctx.ps_sigignore, signo);                          sigaddset(&p->p_sigctx.ps_sigignore, signo);
                 SIGACTION_PS(ps, signo).sa_handler = SIG_DFL;                  SIGACTION_PS(ps, signo).sa_handler = SIG_DFL;
         }          }
           mutex_exit(&ps->sa_mutex);
 }  }
   
 /*  /*

Legend:
Removed from v.1.254.6.4  
changed lines
  Added in v.1.254.6.5

CVSweb <webmaster@jp.NetBSD.org>