1*433d6423SLionel Sambuc /* The kernel call that is implemented in this file: 2*433d6423SLionel Sambuc * m_type: SYS_GETKSIG 3*433d6423SLionel Sambuc * 4*433d6423SLionel Sambuc * The parameters for this kernel call are: 5*433d6423SLionel Sambuc * m_sigcalls.endpt # process with pending signals 6*433d6423SLionel Sambuc * m_sigcalls.map # bit map with pending signals 7*433d6423SLionel Sambuc */ 8*433d6423SLionel Sambuc 9*433d6423SLionel Sambuc #include "kernel/system.h" 10*433d6423SLionel Sambuc #include <signal.h> 11*433d6423SLionel Sambuc #include <minix/endpoint.h> 12*433d6423SLionel Sambuc 13*433d6423SLionel Sambuc #if USE_GETKSIG 14*433d6423SLionel Sambuc 15*433d6423SLionel Sambuc /*===========================================================================* 16*433d6423SLionel Sambuc * do_getksig * 17*433d6423SLionel Sambuc *===========================================================================*/ do_getksig(struct proc * caller,message * m_ptr)18*433d6423SLionel Sambucint do_getksig(struct proc * caller, message * m_ptr) 19*433d6423SLionel Sambuc { 20*433d6423SLionel Sambuc /* The signal manager is ready to accept signals and repeatedly does a kernel 21*433d6423SLionel Sambuc * call to get one. Find a process with pending signals. If no signals are 22*433d6423SLionel Sambuc * available, return NONE in the process number field. 23*433d6423SLionel Sambuc */ 24*433d6423SLionel Sambuc register struct proc *rp; 25*433d6423SLionel Sambuc 26*433d6423SLionel Sambuc /* Find the next process with pending signals. */ 27*433d6423SLionel Sambuc for (rp = BEG_USER_ADDR; rp < END_PROC_ADDR; rp++) { 28*433d6423SLionel Sambuc if (RTS_ISSET(rp, RTS_SIGNALED)) { 29*433d6423SLionel Sambuc if (caller->p_endpoint != priv(rp)->s_sig_mgr) continue; 30*433d6423SLionel Sambuc /* store signaled process' endpoint */ 31*433d6423SLionel Sambuc m_ptr->m_sigcalls.endpt = rp->p_endpoint; 32*433d6423SLionel Sambuc m_ptr->m_sigcalls.map = rp->p_pending; /* pending signals map */ 33*433d6423SLionel Sambuc (void) sigemptyset(&rp->p_pending); /* clear map in the kernel */ 34*433d6423SLionel Sambuc RTS_UNSET(rp, RTS_SIGNALED); /* blocked by SIG_PENDING */ 35*433d6423SLionel Sambuc return(OK); 36*433d6423SLionel Sambuc } 37*433d6423SLionel Sambuc } 38*433d6423SLionel Sambuc 39*433d6423SLionel Sambuc /* No process with pending signals was found. */ 40*433d6423SLionel Sambuc m_ptr->m_sigcalls.endpt = NONE; 41*433d6423SLionel Sambuc return(OK); 42*433d6423SLionel Sambuc } 43*433d6423SLionel Sambuc #endif /* USE_GETKSIG */ 44