xref: /minix/minix/kernel/system/do_kill.c (revision 7f5f010b)
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  *	m_sigcalls.endpt  	# process to signal/ pending
6  *	m_sigcalls.sig		# signal number to send to process
7  */
8 
9 #include "kernel/system.h"
10 #include <signal.h>
11 
12 #if USE_KILL
13 
14 /*===========================================================================*
15  *			          do_kill				     *
16  *===========================================================================*/
17 int do_kill(struct proc * caller, message * m_ptr)
18 {
19 /* Handle sys_kill(). Cause a signal to be sent to a process. Any request
20  * is added to the map of pending signals and the signal manager
21  * associated to the process is informed about the new signal. The signal
22  * is then delivered using POSIX signal handlers for user processes, or
23  * translated into an IPC message for system services.
24  */
25   proc_nr_t proc_nr, proc_nr_e;
26   int sig_nr = m_ptr->m_sigcalls.sig;
27 
28   proc_nr_e = (proc_nr_t)m_ptr->m_sigcalls.endpt;
29 
30   if (!isokendpt(proc_nr_e, &proc_nr)) return(EINVAL);
31   if (sig_nr >= _NSIG) return(EINVAL);
32   if (iskerneln(proc_nr)) return(EPERM);
33 
34   /* Set pending signal to be processed by the signal manager. */
35   cause_sig(proc_nr, sig_nr);
36 
37   return(OK);
38 }
39 
40 #endif /* USE_KILL */
41 
42