housel@en.ecn.purdue.edu (Peter S. Housel) (02/07/89)
This short patch to mm (relative to 1.3d but may well work on the ST) allows signals to be sent to the init process. This capability is used in standard Unix to tell init to re-read /etc/ttys or to revert to single-user. My version of init, included in my next posting, is capable of rereading /etc/ttys. There are also changes relating to INIT_PID. In several places in mm, INIT_PROC_NR is treated as a proc number, and in others as a pid. These changes use INIT_PID for pid's. (Always the purist...) -Peter S. Housel- housel@ecn.purdue.edu ...!pur-ee!housel echo 'x - break.c.cdif' sed 's/^X//' <<'**-break.c.cdif-EOF-**' >break.c.cdif X*** break.c Mon Feb 6 19:57:56 1989 X--- /usr/src/mm/break.c Sat Dec 24 16:17:20 1988 X*************** X*** 84,89 **** X--- 84,91 ---- X mem_sp = &rmp->mp_seg[S]; /* pointer to stack segment map */ X changed = 0; /* set when either segment changed */ X X+ if(rmp - mproc == INIT_PROC_NR) return(OK); /* don't bother init */ X+ X /* See if stack size has gone negative (i.e., sp too close to 0xFFFF...) */ X base_of_stack = (long) mem_sp->mem_vir + (long) mem_sp->mem_len; X sp_click = sp >> CLICK_SHIFT; /* click containing sp */ **-break.c.cdif-EOF-** echo 'x - const.h.cdif' sed 's/^X//' <<'**-const.h.cdif-EOF-**' >const.h.cdif X*** const.h Mon Feb 6 19:59:51 1989 X--- /usr/src/mm/const.h Sat Dec 24 14:29:52 1988 X*************** X*** 23,25 **** X--- 23,27 ---- X X #define HDR_SIZE 32 /* # bytes in the exec file header */ X #define printf printk X+ X+ #define INIT_PID 1 /* init's process id number */ **-const.h.cdif-EOF-** echo 'x - forkexit.c.cdi' sed 's/^X//' <<'**-forkexit.c.cdi-EOF-**' >forkexit.c.cdi X*** forkexit.c Mon Feb 6 19:57:06 1989 X--- /usr/src/mm/forkexit.c Sat Dec 24 16:34:10 1988 X*************** X*** 25,31 **** X X #define LAST_FEW 2 /* last few slots reserved for superuser */ X X! PRIVATE next_pid = INIT_PROC_NR+1; /* next pid to be assigned */ X X /* Some C compilers require static declarations to precede their first use. */ X X--- 25,31 ---- X X #define LAST_FEW 2 /* last few slots reserved for superuser */ X X! PRIVATE next_pid = INIT_PID+1; /* next pid to be assigned */ X X /* Some C compilers require static declarations to precede their first use. */ X X*************** X*** 97,103 **** X /* Find a free pid for the child and put it in the table. */ X do { X t = 0; /* 't' = 0 means pid still free */ X! next_pid = (next_pid < 30000 ? next_pid + 1 : INIT_PROC_NR + 1); X for (rmp = &mproc[0]; rmp < &mproc[NR_PROCS]; rmp++) X if (rmp->mp_pid == next_pid || rmp->mp_procgrp == next_pid) { X t = 1; X--- 97,103 ---- X /* Find a free pid for the child and put it in the table. */ X do { X t = 0; /* 't' = 0 means pid still free */ X! next_pid = (next_pid < 30000 ? next_pid + 1 : INIT_PID + 1); X for (rmp = &mproc[0]; rmp < &mproc[NR_PROCS]; rmp++) X if (rmp->mp_pid == next_pid || rmp->mp_procgrp == next_pid) { X t = 1; **-forkexit.c.cdi-EOF-** echo 'x - main.c.cdif' sed 's/^X//' <<'**-main.c.cdif-EOF-**' >main.c.cdif X*** main.c Mon Feb 6 19:58:50 1989 X--- /usr/src/mm/main.c Sat Dec 24 14:34:27 1988 X*************** X*** 120,125 **** X--- 120,126 ---- X mproc[MM_PROC_NR].mp_flags |= IN_USE; X mproc[FS_PROC_NR].mp_flags |= IN_USE; X mproc[INIT_PROC_NR].mp_flags |= IN_USE; X+ mproc[INIT_PROC_NR].mp_pid = INIT_PID; X procs_in_use = 3; X X /* Set stack limit, which is checked on every procedure call. */ **-main.c.cdif-EOF-** echo 'x - signal.c.cdif' sed 's/^X//' <<'**-signal.c.cdif-EOF-**' >signal.c.cdif X*** signal.c Mon Feb 6 19:55:44 1989 X--- /usr/src/mm/signal.c Mon Feb 6 19:44:16 1989 X*************** X*** 158,164 **** X * - if a process has already exited, it can't receive signals X * - if 'proc_id' is 0 signal everyone in same process group except caller X */ X! for (rmp = &mproc[INIT_PROC_NR + 1]; rmp < &mproc[NR_PROCS]; rmp++ ) { X if ( (rmp->mp_flags & IN_USE) == 0) continue; X send_sig = TRUE; /* if it's FALSE at end of loop, don't signal */ X if (send_uid != rmp->mp_effuid && send_uid != SUPER_USER)send_sig=FALSE; X--- 158,164 ---- X * - if a process has already exited, it can't receive signals X * - if 'proc_id' is 0 signal everyone in same process group except caller X */ X! for (rmp = &mproc[INIT_PROC_NR]; rmp < &mproc[NR_PROCS]; rmp++ ) { X if ( (rmp->mp_flags & IN_USE) == 0) continue; X send_sig = TRUE; /* if it's FALSE at end of loop, don't signal */ X if (send_uid != rmp->mp_effuid && send_uid != SUPER_USER)send_sig=FALSE; X*************** X*** 166,171 **** X--- 166,173 ---- X if (rmp->mp_flags & HANGING) send_sig = FALSE; /*don't wake the dead*/ X if (proc_id == 0 && mp->mp_procgrp != rmp->mp_procgrp) send_sig = FALSE; X if (send_uid == SUPER_USER && proc_id == -1) send_sig = TRUE; X+ if (rmp->mp_pid == INIT_PID && proc_id == -1) send_sig = FALSE; X+ if (rmp->mp_pid == INIT_PID && sig_nr == SIGKILL) send_sig = FALSE; X X /* SIGALARM is a little special. When a process exits, a clock signal X * can arrive just as the timer is being turned off. Also, turn off **-signal.c.cdif-EOF-** exit 0