do_kill.c

Go to the documentation of this file.
00001 /* The kernel call that is implemented in this file:
00002  *   m_type:    SYS_KILL
00003  *
00004  * The parameters for this kernel call are:
00005  *     m2_i1:   SIG_ENDPT       # process to signal/ pending            
00006  *     m2_i2:   SIG_NUMBER      # signal number to send to process
00007  */
00008 
00009 #include "../system.h"
00010 #include <signal.h>
00011 #include <sys/sigcontext.h>
00012 
00013 #if USE_KILL
00014 
00015 /*===========================================================================*
00016  *                                do_kill                                    *
00017  *===========================================================================*/
00018 PUBLIC int do_kill(m_ptr)
00019 message *m_ptr;                 /* pointer to request message */
00020 {
00021 /* Handle sys_kill(). Cause a signal to be sent to a process. The PM is the
00022  * central server where all signals are processed and handler policies can
00023  * be registered. Any request, except for PM requests, is added to the map
00024  * of pending signals and the PM is informed about the new signal.
00025  * Since system servers cannot use normal POSIX signal handlers (because they
00026  * are usually blocked on a RECEIVE), they can request the PM to transform 
00027  * signals into messages. This is done by the PM with a call to sys_kill(). 
00028  */
00029   proc_nr_t proc_nr, proc_nr_e;
00030   int sig_nr = m_ptr->SIG_NUMBER;
00031 
00032   proc_nr_e= m_ptr->SIG_ENDPT;
00033         
00034   if (proc_nr_e == SELF)
00035         proc_nr_e= m_ptr->m_source;
00036 
00037   if (!isokendpt(proc_nr_e, &proc_nr)) return(EINVAL);
00038 
00039   if (sig_nr > _NSIG) return(EINVAL);
00040   if (iskerneln(proc_nr)) return(EPERM);
00041 
00042   /* Set pending signal to be processed by the PM. */
00043   cause_sig(proc_nr, sig_nr);
00044   if (sig_nr == SIGKILL)
00045         clear_endpoint(proc_addr(proc_nr));
00046   return(OK);
00047 }
00048 
00049 #endif /* USE_KILL */
00050 

Generated on Fri Apr 14 22:57:24 2006 for minix by  doxygen 1.4.6