Removed PM signon for INET. Now daemonized in /usr/etc/rc.

SIGTRAP generated in PM (where it belongs / no longer in kernel).
Updated Makefiles: servers are now installed in /usr/sbin.
This commit is contained in:
Jorrit Herder 2005-07-19 12:11:11 +00:00
parent 7d4e914618
commit f2e16763e7
11 changed files with 95 additions and 65 deletions

View file

@ -25,8 +25,8 @@ $(SERVER): $(OBJ)
install -S 512w $@ install -S 512w $@
# install with other servers # install with other servers
install: /usr/sbin/servers/$(SERVER) install: /usr/sbin/$(SERVER)
/usr/sbin/servers/$(SERVER): $(SERVER) /usr/sbin/$(SERVER): $(SERVER)
install -o root -cs $? $@ install -o root -cs $? $@
# clean up local files # clean up local files

View file

@ -28,9 +28,9 @@ all: inet
inet: $(OBJ) inet: $(OBJ)
$(CC) -o $@ $(LDFLAGS) $(OBJ) version.c $(LIBS) $(CC) -o $@ $(LDFLAGS) $(OBJ) version.c $(LIBS)
install: /usr/sbin/servers/inet install: /usr/sbin/inet
/usr/sbin/servers/inet: inet /usr/sbin/inet: inet
install -c $? $@ install -c $? $@
clean: clean:

View file

@ -22,8 +22,8 @@ $(SERVER): $(OBJ)
install -S 192w $@ install -S 192w $@
# install with other servers # install with other servers
install: /usr/sbin/servers/$(SERVER) install: /usr/sbin/$(SERVER)
/usr/sbin/servers/$(SERVER): $(SERVER) /usr/sbin/$(SERVER): $(SERVER)
install -o root -cs $? $@ install -o root -cs $? $@
# clean up local files # clean up local files

View file

@ -26,8 +26,8 @@ $(SERVER): $(OBJ)
# install -S 256w $@ # install -S 256w $@
# install with other servers # install with other servers
install: /usr/sbin/servers/$(SERVER) install: /usr/sbin/$(SERVER)
/usr/sbin/servers/$(SERVER): $(SERVER) /usr/sbin/$(SERVER): $(SERVER)
install -o root -c $? $@ install -o root -c $? $@
# install -o root -cs $? $@ # install -o root -cs $? $@

View file

@ -42,6 +42,7 @@ PUBLIC void main(void)
* sending the reply. The loop never terminates, unless a panic occurs. * sending the reply. The loop never terminates, unless a panic occurs.
*/ */
int result; int result;
sigset_t sigset;
/* Initialize the server, then go to work. */ /* Initialize the server, then go to work. */
init_server(); init_server();
@ -53,9 +54,17 @@ PUBLIC void main(void)
get_work(); get_work();
switch (callnr) { switch (callnr) {
case NEW_KMESS: case SYS_EVENT:
result = do_new_kmess(&m_in); sigset = (sigset_t) m_in.NOTIFY_ARG;
break; if (sigismember(&sigset, SIGKMESS)) {
printf("IS proc SIGKMESS\n");
result = do_new_kmess(&m_in);
} else if (sigismember(&sigset, SIGTERM)) {
printf("IS proc SIGTERM\n");
} else {
report("IS","warning, got unknown signal", NO_NUM);
}
continue;
case DIAGNOSTICS: case DIAGNOSTICS:
result = do_diagnostics(&m_in); result = do_diagnostics(&m_in);
break; break;
@ -103,8 +112,8 @@ PRIVATE void init_server()
int i, s; int i, s;
struct sigaction sigact; struct sigaction sigact;
/* Install signal handler.*/ /* Install signal handler. Ask PM to transform signal into message. */
sigact.sa_handler = signal_handler; sigact.sa_handler = SIG_MESS;
sigact.sa_mask = ~0; /* block all other signals */ sigact.sa_mask = ~0; /* block all other signals */
sigact.sa_flags = 0; /* default behaviour */ sigact.sa_flags = 0; /* default behaviour */
if (sigaction(SIGTERM, &sigact, NULL) != OK) if (sigaction(SIGTERM, &sigact, NULL) != OK)

View file

@ -23,8 +23,8 @@ $(SERVER): $(OBJ)
install -S 256w $@ install -S 256w $@
# install with other servers # install with other servers
install: /usr/sbin/servers/$(SERVER) install: /usr/sbin/$(SERVER)
/usr/sbin/servers/$(SERVER): $(SERVER) /usr/sbin/$(SERVER): $(SERVER)
install -o root -cs $? $@ install -o root -cs $? $@
# clean up local files # clean up local files

View file

@ -178,6 +178,8 @@ PUBLIC int do_exec()
rmp->mp_name[PROC_NAME_LEN] = '\0'; rmp->mp_name[PROC_NAME_LEN] = '\0';
sys_exec(who, new_sp, rmp->mp_flags & TRACED, basename, pc); sys_exec(who, new_sp, rmp->mp_flags & TRACED, basename, pc);
if (rmp->mp_flags & TRACED) check_sig(rmp->mp_pid, SIGTRAP);
return(SUSPEND); /* no reply, new program just runs */ return(SUSPEND); /* no reply, new program just runs */
} }

View file

@ -41,9 +41,9 @@ FORWARD _PROTOTYPE( void patch_mem_chunks, (struct memory *mem_chunks,
PUBLIC void main() PUBLIC void main()
{ {
/* Main routine of the process manager. */ /* Main routine of the process manager. */
int result, s, proc_nr; int result, s, proc_nr;
struct mproc *rmp; struct mproc *rmp;
sigset_t sigset;
pm_init(); /* initialize process manager tables */ pm_init(); /* initialize process manager tables */
@ -55,8 +55,11 @@ PUBLIC void main()
if (call_nr == SYN_ALARM) { if (call_nr == SYN_ALARM) {
pm_expire_timers(m_in.NOTIFY_TIMESTAMP); pm_expire_timers(m_in.NOTIFY_TIMESTAMP);
result = SUSPEND; /* don't reply */ result = SUSPEND; /* don't reply */
} else if (call_nr == KSIG_PENDING) { /* signals pending */ } else if (call_nr == SYS_EVENT) { /* signals pending */
(void) ksig_pending(); sigset = m_in.NOTIFY_ARG;
if (sigismember(&sigset, SIGKSIG)) {
(void) ksig_pending();
}
result = SUSPEND; /* don't reply */ result = SUSPEND; /* don't reply */
} }
/* Else, if the system call number is valid, perform the call. */ /* Else, if the system call number is valid, perform the call. */
@ -103,7 +106,8 @@ PRIVATE void get_work()
call_nr = m_in.m_type; /* system call number */ call_nr = m_in.m_type; /* system call number */
/* Process slot of caller. Misuse PM's own process slot if the kernel is /* Process slot of caller. Misuse PM's own process slot if the kernel is
* calling. The can happen in case of pending kernel signals. * calling. This can happen in case of synchronous alarms (CLOCK) or or
* event like pending kernel signals (SYSTEM).
*/ */
mp = &mproc[who < 0 ? PM_PROC_NR : who]; mp = &mproc[who < 0 ? PM_PROC_NR : who];
} }
@ -142,7 +146,6 @@ PRIVATE void pm_init()
static char core_sigs[] = { SIGQUIT, SIGILL, SIGTRAP, SIGABRT, static char core_sigs[] = { SIGQUIT, SIGILL, SIGTRAP, SIGABRT,
SIGEMT, SIGFPE, SIGUSR1, SIGSEGV, SIGUSR2 }; SIGEMT, SIGFPE, SIGUSR1, SIGSEGV, SIGUSR2 };
static char ign_sigs[] = { SIGCHLD }; static char ign_sigs[] = { SIGCHLD };
register int proc_nr;
register struct mproc *rmp; register struct mproc *rmp;
register char *sig_ptr; register char *sig_ptr;
phys_clicks total_clicks, minix_clicks, free_clicks; phys_clicks total_clicks, minix_clicks, free_clicks;
@ -193,13 +196,23 @@ PRIVATE void pm_init()
/* Set process details found in the image table. */ /* Set process details found in the image table. */
rmp = &mproc[ip->proc_nr]; rmp = &mproc[ip->proc_nr];
rmp->mp_flags |= IN_USE | DONT_SWAP;
rmp->mp_pid = get_free_pid();
rmp->mp_parent = INIT_PROC_NR;
strncpy(rmp->mp_name, ip->proc_name, PROC_NAME_LEN); strncpy(rmp->mp_name, ip->proc_name, PROC_NAME_LEN);
sigfillset(&rmp->mp_ignore); if (ip->proc_nr == INIT_PROC_NR) { /* user process */
sigfillset(&rmp->mp_sigmask); rmp->mp_pid = INIT_PID;
rmp->mp_parent = PM_PROC_NR;
rmp->mp_flags |= IN_USE;
sigemptyset(&rmp->mp_ignore);
rmp->mp_nice = 0;
}
else { /* system process */
rmp->mp_pid = get_free_pid();
rmp->mp_parent = INIT_PROC_NR;
rmp->mp_flags |= IN_USE | DONT_SWAP | PRIV_PROC;
sigfillset(&rmp->mp_ignore);
}
sigemptyset(&rmp->mp_sigmask);
sigemptyset(&rmp->mp_catch); sigemptyset(&rmp->mp_catch);
sigemptyset(&rmp->mp_sig2mess);
/* Get memory map for this process from the kernel. */ /* Get memory map for this process from the kernel. */
if ((s=get_mem_map(ip->proc_nr, rmp->mp_seg)) != OK) if ((s=get_mem_map(ip->proc_nr, rmp->mp_seg)) != OK)
@ -217,15 +230,7 @@ PRIVATE void pm_init()
} }
} }
/* PM and INIT are somewhat special. Override some details. Set signal /* PM is somewhat special. Override some details. */
* handling behaviour for PM, since PM cannot call sigaction() as others.
*/
mproc[INIT_PROC_NR].mp_pid = INIT_PID;
mproc[INIT_PROC_NR].mp_nice = 0;
mproc[INIT_PROC_NR].mp_parent = PM_PROC_NR;
sigemptyset(&mproc[INIT_PROC_NR].mp_ignore);
sigemptyset(&mproc[INIT_PROC_NR].mp_sigmask);
mproc[PM_PROC_NR].mp_pid = PM_PID; mproc[PM_PROC_NR].mp_pid = PM_PID;
mproc[PM_PROC_NR].mp_parent = PM_PROC_NR; mproc[PM_PROC_NR].mp_parent = PM_PROC_NR;

View file

@ -183,13 +183,13 @@ PUBLIC int do_getsetpriority()
/* Only support PRIO_PROCESS for now. */ /* Only support PRIO_PROCESS for now. */
if(arg_which != PRIO_PROCESS) if(arg_which != PRIO_PROCESS)
return EINVAL; return(EINVAL);
if(arg_who == 0) if(arg_who == 0)
rmp_nr = who; rmp_nr = who;
else else
if((rmp_nr = proc_from_pid(arg_who)) < 0) if((rmp_nr = proc_from_pid(arg_who)) < 0)
return ESRCH; return(ESRCH);
rmp = &mproc[rmp_nr]; rmp = &mproc[rmp_nr];
@ -198,18 +198,17 @@ PUBLIC int do_getsetpriority()
return EPERM; return EPERM;
/* If GET, that's it. */ /* If GET, that's it. */
if(call_nr == GETPRIORITY) { if(call_nr == GETPRIORITY) {
return rmp->mp_nice - PRIO_MIN; return(rmp->mp_nice - PRIO_MIN);
} }
/* Only root is allowed to reduce the nice level. */ /* Only root is allowed to reduce the nice level. */
if(rmp->mp_nice > arg_pri && mp->mp_effuid != SUPER_USER) if(rmp->mp_nice > arg_pri && mp->mp_effuid != SUPER_USER)
return EACCES; return(EACCES);
/* We're SET, and it's allowed. Do it and tell kernel. */ /* We're SET, and it's allowed. Do it and tell kernel. */
rmp->mp_nice = arg_pri; rmp->mp_nice = arg_pri;
return sys_setpriority(rmp_nr, arg_pri); return sys_nice(rmp_nr, arg_pri);
} }
/*=====================================================================* /*=====================================================================*
@ -280,6 +279,7 @@ PUBLIC int do_svrctl()
return OK; return OK;
} }
case MMSIGNON: { case MMSIGNON: {
#if DEAD_CODE
/* A user process becomes a task. Simulate an exit by /* A user process becomes a task. Simulate an exit by
* releasing a waiting parent and disinheriting children. * releasing a waiting parent and disinheriting children.
*/ */
@ -307,10 +307,7 @@ PUBLIC int do_svrctl()
rmp->mp_parent = INIT_PROC_NR; rmp->mp_parent = INIT_PROC_NR;
} }
} }
#endif
/* Become like PM and FS. */
mp->mp_pid = mp->mp_procgrp = 0;
mp->mp_parent = 0;
return(OK); } return(OK); }
#if ENABLE_SWAP #if ENABLE_SWAP

View file

@ -33,6 +33,7 @@ EXTERN struct mproc {
/* Signal handling information. */ /* Signal handling information. */
sigset_t mp_ignore; /* 1 means ignore the signal, 0 means don't */ sigset_t mp_ignore; /* 1 means ignore the signal, 0 means don't */
sigset_t mp_catch; /* 1 means catch the signal, 0 means don't */ sigset_t mp_catch; /* 1 means catch the signal, 0 means don't */
sigset_t mp_sig2mess; /* 1 means transform into notify message */
sigset_t mp_sigmask; /* signals to be blocked */ sigset_t mp_sigmask; /* signals to be blocked */
sigset_t mp_sigmask2; /* saved copy of mp_sigmask */ sigset_t mp_sigmask2; /* saved copy of mp_sigmask */
sigset_t mp_sigpending; /* pending signals to be handled */ sigset_t mp_sigpending; /* pending signals to be handled */
@ -68,6 +69,7 @@ EXTERN struct mproc {
#define ONSWAP 0x400 /* set if data segment is swapped out */ #define ONSWAP 0x400 /* set if data segment is swapped out */
#define SWAPIN 0x800 /* set if on the "swap this in" queue */ #define SWAPIN 0x800 /* set if on the "swap this in" queue */
#define DONT_SWAP 0x1000 /* never swap out this process */ #define DONT_SWAP 0x1000 /* never swap out this process */
#define PRIV_PROC 0x2000 /* system process, special privileges */
#define NIL_MPROC ((struct mproc *) 0) #define NIL_MPROC ((struct mproc *) 0)

View file

@ -1,4 +1,3 @@
#define NEW_AL 1
/* This file handles signals, which are asynchronous events and are generally /* This file handles signals, which are asynchronous events and are generally
* a messy and unpleasant business. Signals can be generated by the KILL * a messy and unpleasant business. Signals can be generated by the KILL
* system call, or from the keyboard (SIGINT) or from the clock (SIGALRM). * system call, or from the keyboard (SIGINT) or from the clock (SIGALRM).
@ -71,12 +70,20 @@ PUBLIC int do_sigaction()
sigaddset(&mp->mp_ignore, m_in.sig_nr); sigaddset(&mp->mp_ignore, m_in.sig_nr);
sigdelset(&mp->mp_sigpending, m_in.sig_nr); sigdelset(&mp->mp_sigpending, m_in.sig_nr);
sigdelset(&mp->mp_catch, m_in.sig_nr); sigdelset(&mp->mp_catch, m_in.sig_nr);
sigdelset(&mp->mp_sig2mess, m_in.sig_nr);
} else if (svec.sa_handler == SIG_DFL) {
sigdelset(&mp->mp_ignore, m_in.sig_nr);
sigdelset(&mp->mp_catch, m_in.sig_nr);
sigdelset(&mp->mp_sig2mess, m_in.sig_nr);
} else if (svec.sa_handler == SIG_MESS) {
if (! (mp->mp_flags & PRIV_PROC)) return(EPERM);
sigdelset(&mp->mp_ignore, m_in.sig_nr);
sigaddset(&mp->mp_sig2mess, m_in.sig_nr);
sigdelset(&mp->mp_catch, m_in.sig_nr);
} else { } else {
sigdelset(&mp->mp_ignore, m_in.sig_nr); sigdelset(&mp->mp_ignore, m_in.sig_nr);
if (svec.sa_handler == SIG_DFL) sigaddset(&mp->mp_catch, m_in.sig_nr);
sigdelset(&mp->mp_catch, m_in.sig_nr); sigdelset(&mp->mp_sig2mess, m_in.sig_nr);
else
sigaddset(&mp->mp_catch, m_in.sig_nr);
} }
mp->mp_sigact[m_in.sig_nr].sa_handler = svec.sa_handler; mp->mp_sigact[m_in.sig_nr].sa_handler = svec.sa_handler;
sigdelset(&svec.sa_mask, SIGKILL); sigdelset(&svec.sa_mask, SIGKILL);
@ -376,14 +383,16 @@ register struct mproc *rmp; /* pointer to the process to be signaled */
int signo; /* signal to send to process (1 to _NSIG) */ int signo; /* signal to send to process (1 to _NSIG) */
{ {
/* Send a signal to a process. Check to see if the signal is to be caught, /* Send a signal to a process. Check to see if the signal is to be caught,
* ignored, or blocked. If the signal is to be caught, coordinate with * ignored, tranformed into a message (for system processes) or blocked.
* KERNEL to push a sigcontext structure and a sigframe structure onto * - If the signal is to be transformed into a message, request the KERNEL to
* the catcher's stack. Also, KERNEL will reset the program counter and * send the target process a system notification with the pending signal as an
* stack pointer, so that when the process next runs, it will be executing * argument.
* the signal handler. When the signal handler returns, sigreturn(2) * - If the signal is to be caught, request the KERNEL to push a sigcontext
* will be called. Then KERNEL will restore the signal context from the * structure and a sigframe structure onto the catcher's stack. Also, KERNEL
* sigcontext structure. * will reset the program counter and stack pointer, so that when the process
* * next runs, it will be executing the signal handler. When the signal handler
* returns, sigreturn(2) will be called. Then KERNEL will restore the signal
* context from the sigcontext structure.
* If there is insufficient stack space, kill the process. * If there is insufficient stack space, kill the process.
*/ */
@ -410,21 +419,21 @@ int signo; /* signal to send to process (1 to _NSIG) */
DEBUG(m_in.pid == 11, printf("PM: sig_proc ignored sig\n")); DEBUG(m_in.pid == 11, printf("PM: sig_proc ignored sig\n"));
return; return;
} }
if (sigismember(&rmp->mp_sigmask, signo)) { if (sigismember(&rmp->mp_sigmask, signo)) {
/* Signal should be blocked. */ /* Signal should be blocked. */
sigaddset(&rmp->mp_sigpending, signo); sigaddset(&rmp->mp_sigpending, signo);
return; return;
} }
if (rmp->mp_flags & ONSWAP) {
/* Process is swapped out, leave signal pending. */
sigaddset(&rmp->mp_sigpending, signo);
swap_inqueue(rmp);
return;
}
sigflags = rmp->mp_sigact[signo].sa_flags; sigflags = rmp->mp_sigact[signo].sa_flags;
if (sigismember(&rmp->mp_catch, signo)) { if (sigismember(&rmp->mp_catch, signo)) {
DEBUG(m_in.pid == 11, printf("PM: sig_proc catch sig!\n")); DEBUG(m_in.pid == 11, printf("PM: sig_proc catch sig!\n"));
if (rmp->mp_flags & ONSWAP) {
/* Process is swapped out, leave signal pending. */
sigaddset(&rmp->mp_sigpending, signo);
swap_inqueue(rmp);
return;
}
if (rmp->mp_flags & SIGSUSPENDED) if (rmp->mp_flags & SIGSUSPENDED)
sm.sm_mask = rmp->mp_sigmask2; sm.sm_mask = rmp->mp_sigmask2;
else else
@ -466,6 +475,12 @@ int signo; /* signal to send to process (1 to _NSIG) */
} }
panic(__FILE__, "warning, sys_sigsend failed", s); panic(__FILE__, "warning, sys_sigsend failed", s);
} }
else if (sigismember(&rmp->mp_sig2mess, signo)) {
if (OK != (s=sys_kill(slot,signo)))
panic(__FILE__, "warning, sys_kill failed", s);
return;
}
doterminate: doterminate:
DEBUG(m_in.pid == 11, printf("PM: sig_proc doterminate\n")); DEBUG(m_in.pid == 11, printf("PM: sig_proc doterminate\n"));
/* Signal should not or cannot be caught. Take default action. */ /* Signal should not or cannot be caught. Take default action. */