New signal handling behaviour at PM (services can be killed).
New Shift-F6 dump for RS server at IS. New getnpid, getnproc, getpproc library calls at PM. New reincarnation server (basic functionality is there now).
This commit is contained in:
@@ -38,6 +38,8 @@ PUBLIC int do_getset()
|
||||
case GETPID:
|
||||
r = mproc[who].mp_pid;
|
||||
rmp->mp_reply.reply_res2 = mproc[rmp->mp_parent].mp_pid;
|
||||
if (m_in.procnr >= 0 && m_in.procnr < NR_PROCS)
|
||||
rmp->mp_reply.reply_res3 = mproc[m_in.procnr].mp_pid;
|
||||
break;
|
||||
|
||||
case SETUID:
|
||||
|
||||
@@ -155,7 +155,9 @@ PRIVATE void pm_init()
|
||||
static char core_sigs[] = { SIGQUIT, SIGILL, SIGTRAP, SIGABRT,
|
||||
SIGEMT, SIGFPE, SIGUSR1, SIGSEGV, SIGUSR2 };
|
||||
static char ign_sigs[] = { SIGCHLD, SIGWINCH };
|
||||
static char mess_sigs[] = { SIGTERM, SIGHUP, SIGABRT, SIGQUIT };
|
||||
register struct mproc *rmp;
|
||||
register int i;
|
||||
register char *sig_ptr;
|
||||
phys_clicks total_clicks, minix_clicks, free_clicks;
|
||||
message mess;
|
||||
@@ -209,19 +211,24 @@ PRIVATE void pm_init()
|
||||
strncpy(rmp->mp_name, ip->proc_name, PROC_NAME_LEN);
|
||||
rmp->mp_parent = RS_PROC_NR;
|
||||
rmp->mp_nice = get_nice_value(ip->priority);
|
||||
sigemptyset(&rmp->mp_sig2mess);
|
||||
sigemptyset(&rmp->mp_ignore);
|
||||
sigemptyset(&rmp->mp_sigmask);
|
||||
sigemptyset(&rmp->mp_catch);
|
||||
if (ip->proc_nr == INIT_PROC_NR) { /* user process */
|
||||
rmp->mp_pid = INIT_PID;
|
||||
rmp->mp_flags |= IN_USE;
|
||||
sigemptyset(&rmp->mp_ignore);
|
||||
}
|
||||
else { /* system process */
|
||||
rmp->mp_pid = get_free_pid();
|
||||
rmp->mp_flags |= IN_USE | DONT_SWAP | PRIV_PROC;
|
||||
sigfillset(&rmp->mp_ignore);
|
||||
#if DEAD_CODE
|
||||
for (sig_ptr = mess_sigs;
|
||||
sig_ptr < mess_sigs+sizeof(mess_sigs);
|
||||
sig_ptr++)
|
||||
sigaddset(&rmp->mp_sig2mess, *sig_ptr);
|
||||
#endif
|
||||
}
|
||||
sigemptyset(&rmp->mp_sigmask);
|
||||
sigemptyset(&rmp->mp_catch);
|
||||
sigemptyset(&rmp->mp_sig2mess);
|
||||
|
||||
/* Get memory map for this process from the kernel. */
|
||||
if ((s=get_mem_map(ip->proc_nr, rmp->mp_seg)) != OK)
|
||||
@@ -241,9 +248,11 @@ PRIVATE void pm_init()
|
||||
}
|
||||
printf(".\n"); /* last process done */
|
||||
|
||||
/* Override some details. PM is somewhat special. */
|
||||
mproc[PM_PROC_NR].mp_pid = PM_PID; /* magically override pid */
|
||||
mproc[PM_PROC_NR].mp_parent = PM_PROC_NR; /* PM doesn't have parent */
|
||||
/* Override some details. INIT, PM, FS and RS are somewhat special. */
|
||||
mproc[PM_PROC_NR].mp_pid = PM_PID; /* PM has magic pid */
|
||||
mproc[RS_PROC_NR].mp_parent = INIT_PROC_NR; /* INIT is root */
|
||||
sigfillset(&mproc[PM_PROC_NR].mp_ignore); /* guard against signals */
|
||||
sigfillset(&mproc[FS_PROC_NR].mp_sig2mess); /* forward signals */
|
||||
|
||||
/* Tell FS that no more system processes follow and synchronize. */
|
||||
mess.PR_PROC_NR = NONE;
|
||||
|
||||
@@ -95,7 +95,7 @@ PUBLIC int do_getprocnr()
|
||||
int key_len;
|
||||
int s;
|
||||
|
||||
if (m_in.pid >= 0) { /* lookup process by pid */
|
||||
if (m_in.pid >= 0) { /* lookup process by pid */
|
||||
for (rmp = &mproc[0]; rmp < &mproc[NR_PROCS]; rmp++) {
|
||||
if ((rmp->mp_flags & IN_USE) && (rmp->mp_pid==m_in.pid)) {
|
||||
mp->mp_reply.procnr = (int) (rmp - mproc);
|
||||
@@ -103,7 +103,7 @@ PUBLIC int do_getprocnr()
|
||||
}
|
||||
}
|
||||
return(ESRCH);
|
||||
} else if (m_in.namelen > 0) { /* lookup process by name */
|
||||
} else if (m_in.namelen > 0) { /* lookup process by name */
|
||||
key_len = MIN(m_in.namelen, PROC_NAME_LEN);
|
||||
if (OK != (s=sys_datacopy(who, (vir_bytes) m_in.addr,
|
||||
SELF, (vir_bytes) search_key, key_len)))
|
||||
@@ -117,8 +117,9 @@ PUBLIC int do_getprocnr()
|
||||
}
|
||||
}
|
||||
return(ESRCH);
|
||||
} else { /* return own process number */
|
||||
} else { /* return own/parent process number */
|
||||
mp->mp_reply.procnr = who;
|
||||
mp->mp_reply.pprocnr = mp->mp_parent;
|
||||
}
|
||||
return(OK);
|
||||
}
|
||||
@@ -159,8 +160,8 @@ PUBLIC int do_reboot()
|
||||
return(EINVAL);
|
||||
}
|
||||
|
||||
tell_fs(REBOOT, 0, 0, 0); /* tell FS to synchronize */
|
||||
check_sig(-1, SIGKILL); /* kill all processes except init */
|
||||
tell_fs(REBOOT,0,0,0); /* tell FS to prepare for shutdown */
|
||||
|
||||
/* Ask the kernel to abort. All system services, including the PM, will
|
||||
* get a HARD_STOP notification. Await the notification in the main loop.
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#define namelen m1_i2
|
||||
#define pid m1_i1
|
||||
#define procnr m1_i1
|
||||
#define pprocnr m1_i2
|
||||
#define seconds m1_i1
|
||||
#define sig m6_i1
|
||||
#define stack_bytes m1_i2
|
||||
@@ -41,6 +42,7 @@
|
||||
/* The following names are synonyms for the variables in a reply message. */
|
||||
#define reply_res m_type
|
||||
#define reply_res2 m2_i1
|
||||
#define reply_res3 m2_i2
|
||||
#define reply_ptr m2_p1
|
||||
#define reply_mask m2_l1
|
||||
#define reply_trace m2_l2
|
||||
|
||||
@@ -257,12 +257,6 @@ sigset_t sig_map;
|
||||
id = 0; break; /* broadcast to process group */
|
||||
case SIGKILL:
|
||||
id = -1; break; /* broadcast to all except INIT */
|
||||
#if DEAD_CODE
|
||||
case SIGALRM:
|
||||
if ((rmp->mp_flags & ALARM_ON) == 0) continue;
|
||||
rmp->mp_flags &= ~ALARM_ON;
|
||||
/* fall through */
|
||||
#endif
|
||||
default:
|
||||
id = proc_id;
|
||||
break;
|
||||
|
||||
@@ -113,9 +113,21 @@ int num; /* number to go with it */
|
||||
* defined constant. The process manager decides to shut down. This results
|
||||
* in a HARD_STOP notification to all system processes to allow local cleanup.
|
||||
*/
|
||||
message m;
|
||||
int s;
|
||||
|
||||
/* Switch to primary console and print panic message. */
|
||||
check_sig(mproc[TTY_PROC_NR].mp_pid, SIGTERM);
|
||||
printf("PM panic (%s): %s", who, mess);
|
||||
if (num != NO_NUM) printf(": %d",num);
|
||||
printf("\n");
|
||||
|
||||
/* Allow for debug dumps if the IS server is available. */
|
||||
m.m_type = PANIC_DUMPS;
|
||||
if (OK == (s= nb_send(11, &m))) {
|
||||
return; /* IS responsible for exit */
|
||||
}
|
||||
printf("Shutting down: IS is not answering: %d\n", s);
|
||||
sys_abort(RBT_PANIC);
|
||||
}
|
||||
|
||||
@@ -135,9 +147,13 @@ int what, p1, p2, p3;
|
||||
* tell_fs(SETUID, proc, realuid, effuid)
|
||||
* tell_fs(UNPAUSE, proc, signr, 0)
|
||||
* tell_fs(STIME, time, 0, 0)
|
||||
* Ignore this call if the FS is already dead, e.g. on shutdown.
|
||||
*/
|
||||
message m;
|
||||
|
||||
if ((mproc[FS_PROC_NR].mp_flags & (IN_USE|ZOMBIE)) != IN_USE)
|
||||
return;
|
||||
|
||||
m.tell_fs_arg1 = p1;
|
||||
m.tell_fs_arg2 = p2;
|
||||
m.tell_fs_arg3 = p3;
|
||||
|
||||
Reference in New Issue
Block a user