panic() cleanup.
[minix.git] / kernel / system / do_getksig.c
blob7c05c83b85eb2d93962988917587bb9ba3b4a89b
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 "../system.h"
10 #include <signal.h>
11 #include <minix/endpoint.h>
13 #if USE_GETKSIG
15 /*===========================================================================*
16 * do_getksig *
17 *===========================================================================*/
18 PUBLIC int do_getksig(struct proc * caller, message * m_ptr)
20 /* PM is ready to accept signals and repeatedly does a kernel call to get
21 * one. Find a process with pending signals. If no signals are available,
22 * return NONE in the process number field.
23 * It is not sufficient to ready the process when PM is informed, because
24 * PM can block waiting for FS to do a core dump.
26 register struct proc *rp;
28 /* Find the next process with pending signals. */
29 for (rp = BEG_USER_ADDR; rp < END_PROC_ADDR; rp++) {
30 if (RTS_ISSET(rp, RTS_SIGNALED)) {
31 /* store signaled process' endpoint */
32 m_ptr->SIG_ENDPT = rp->p_endpoint;
33 m_ptr->SIG_MAP = rp->p_pending; /* pending signals map */
34 sigemptyset(&rp->p_pending); /* ball is in PM's court */
35 RTS_UNSET(rp, RTS_SIGNALED); /* blocked by SIG_PENDING */
36 return(OK);
40 /* No process with pending signals was found. */
41 m_ptr->SIG_ENDPT = NONE;
42 return(OK);
44 #endif /* USE_GETKSIG */