[comp.os.minix] SIGNAL Handling Problems

hubble@cae780.UUCP (05/08/87)

In trying to get multiple users running under MINIX, I have encountered
and fixed several bugs.  The bugs are all related to SIGNALs and Process
groups.

The first is in mm/signal.c.  When the alarm(seconds) system call is made,
the process number is stuffed into the wrong message type.  This works
now by accident if there is only one alarm pending and since there is a
bug in process groups (they are always zero).  The process number always
ends up zero, which looks through all processes in the group (since they
are all zero, that means all processes) and ends up waking all alarm waits
at the earliest alarm time.  The line in routine set_alarm() now is:

    m_sig.PROC_NR = proc_nr;

and should be:

    m_sig.CLOCK_PROC_NR = proc_nr;


The second is also in mm/signal.c.  In routine do_ksig(), signals generated
by by the kernel are pretended to come from MM.  However, this does not handle
process groups properly.  This can be cured by setting MM process group to
that of the desired calling process.  After the line that now reads:
   mp = &mproc[0];      /* pretend kernel signals are from MM */

add the following line:

   mp->mp_procgrp = rmp->mp_procgrp; /* get the process group right */


Third and last, the process group is never set to anything.  Which means
it is always zero now.  I'm not sure what I did is the best answer, but
it works.  In mm/forkexit.c when a fork is done, do_fork() now looks to
see if the parent doing the fork is INIT.  If it is INIT, a new PRIVATE
variable (process_group) is incremented and put in the process table. 
If the parent is not INIT, the child inherits the parents process group.
The new PRIVATE global was added:

    PRIVATE process_group = 1;  /* next process group to be assigned */

add the following code was added after do_fork() copies the parents 'mproc'
slot to the child's:

    if (who == INIT_PROC_NR)
	rmc->mp_procgrp = process_group++;

This essentially makes all processes started from the same terminal in
the same process group.  This fix is required to get interrupts to work
on multiple terminals/users.


--------------------------------------------------------------------------
		    Larry R. Hubble        Tektronix/CAE Systems Division
	            (408) 296-3593	   5302 Betsy Ross Dr.
        {hplabs,tektronix}!hubble@cae780   Santa Clara, CA 95054