source: branches/minix3-book/kernel/system/do_kill.c@ 4

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

Importazione sorgenti libro

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_PROC # 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 = m_ptr->SIG_PROC;
30 int sig_nr = m_ptr->SIG_NUMBER;
31
32 if (! isokprocn(proc_nr) || sig_nr > _NSIG) return(EINVAL);
33 if (iskerneln(proc_nr)) return(EPERM);
34
35 if (m_ptr->m_source == PM_PROC_NR) {
36 /* Directly send signal notification to a system process. */
37 if (! (priv(proc_addr(proc_nr))->s_flags & SYS_PROC)) return(EPERM);
38 send_sig(proc_nr, sig_nr);
39 } else {
40 /* Set pending signal to be processed by the PM. */
41 cause_sig(proc_nr, sig_nr);
42 }
43 return(OK);
44}
45
46#endif /* USE_KILL */
47
Note: See TracBrowser for help on using the repository browser.