source: trunk/minix/kernel/system/do_kill.c@ 9

Last change on this file since 9 was 9, checked in by Mattia Monga, 13 years ago

Minix 3.1.2a

File size: 1.6 KB
Line 
1/* The kernel call that is implemented in this file:
2 * m_type: SYS_KILL
3 *
4 * The parameters for this kernel call are:
5 * m2_i1: SIG_ENDPT # process to signal/ pending
6 * m2_i2: SIG_NUMBER # signal number to send to process
7 */
8
9#include "../system.h"
10#include <signal.h>
11#include <sys/sigcontext.h>
12
13#if USE_KILL
14
15/*===========================================================================*
16 * do_kill *
17 *===========================================================================*/
18PUBLIC int do_kill(m_ptr)
19message *m_ptr; /* pointer to request message */
20{
21/* Handle sys_kill(). Cause a signal to be sent to a process. The PM is the
22 * central server where all signals are processed and handler policies can
23 * be registered. Any request, except for PM requests, is added to the map
24 * of pending signals and the PM is informed about the new signal.
25 * Since system servers cannot use normal POSIX signal handlers (because they
26 * are usually blocked on a RECEIVE), they can request the PM to transform
27 * signals into messages. This is done by the PM with a call to sys_kill().
28 */
29 proc_nr_t proc_nr, proc_nr_e;
30 int sig_nr = m_ptr->SIG_NUMBER;
31
32 proc_nr_e= m_ptr->SIG_ENDPT;
33
34 if (proc_nr_e == SELF)
35 proc_nr_e= m_ptr->m_source;
36
37 if (!isokendpt(proc_nr_e, &proc_nr)) return(EINVAL);
38
39 if (sig_nr > _NSIG) return(EINVAL);
40 if (iskerneln(proc_nr)) return(EPERM);
41
42 /* Set pending signal to be processed by the PM. */
43 cause_sig(proc_nr, sig_nr);
44 if (sig_nr == SIGKILL)
45 clear_endpoint(proc_addr(proc_nr));
46 return(OK);
47}
48
49#endif /* USE_KILL */
50
Note: See TracBrowser for help on using the repository browser.