ramdisk Makefile: CLEANFILES fix
[minix.git] / kernel / system / do_getksig.c
blob0235fcc3bba148a0800787d2f0031b141853f3fb
1 /* The kernel call that is implemented in this file:
2 * m_type: SYS_GETKSIG
4 * The parameters for this kernel call are:
5 * m2_i1: SIG_ENDPT # process with pending signals
6 * m2_l1: SIG_MAP # bit map with pending signals
7 */
9 #include "kernel/system.h"
10 #include <signal.h>
11 #include <minix/endpoint.h>
13 #if USE_GETKSIG
15 /*===========================================================================*
16 * do_getksig *
17 *===========================================================================*/
18 int do_getksig(struct proc * caller, message * m_ptr)
20 /* The signal manager is ready to accept signals and repeatedly does a kernel
21 * call to get one. Find a process with pending signals. If no signals are
22 * available, return NONE in the process number field.
24 register struct proc *rp;
26 /* Find the next process with pending signals. */
27 for (rp = BEG_USER_ADDR; rp < END_PROC_ADDR; rp++) {
28 if (RTS_ISSET(rp, RTS_SIGNALED)) {
29 if (caller->p_endpoint != priv(rp)->s_sig_mgr) continue;
30 /* store signaled process' endpoint */
31 m_ptr->SIG_ENDPT = rp->p_endpoint;
32 m_ptr->SIG_MAP = rp->p_pending; /* pending signals map */
33 (void) sigemptyset(&rp->p_pending); /* clear map in the kernel */
34 RTS_UNSET(rp, RTS_SIGNALED); /* blocked by SIG_PENDING */
35 return(OK);
39 /* No process with pending signals was found. */
40 m_ptr->SIG_ENDPT = NONE;
41 return(OK);
43 #endif /* USE_GETKSIG */