Minor fixes for RS. Install signal handlers.
This commit is contained in:
parent
2eca6f9374
commit
ee1f2bcb39
|
@ -290,7 +290,15 @@ PRIVATE struct driver w_dtab = {
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
PUBLIC int main()
|
PUBLIC int main()
|
||||||
{
|
{
|
||||||
/* Set special disk parameters then call the generic main loop. */
|
/* Install signal handlers. Ask PM to transform signal into message. */
|
||||||
|
struct sigaction sa;
|
||||||
|
|
||||||
|
sa.sa_handler = SIG_MESS;
|
||||||
|
sigemptyset(&sa.sa_mask);
|
||||||
|
sa.sa_flags = 0;
|
||||||
|
if (sigaction(SIGTERM,&sa,NULL)<0) panic("RS","sigaction failed", errno);
|
||||||
|
|
||||||
|
/* Set special disk parameters then call the generic main loop. */
|
||||||
init_params();
|
init_params();
|
||||||
signal(SIGTERM, SIG_IGN);
|
signal(SIGTERM, SIG_IGN);
|
||||||
driver_task(&w_dtab);
|
driver_task(&w_dtab);
|
||||||
|
|
|
@ -31,8 +31,8 @@ $(LIBDRIVER):
|
||||||
|
|
||||||
|
|
||||||
# install with other drivers
|
# install with other drivers
|
||||||
install: /usr/sbin/$(DRIVER)
|
install: /sbin/$(DRIVER)
|
||||||
/usr/sbin/$(DRIVER): $(DRIVER)
|
/sbin/$(DRIVER): $(DRIVER)
|
||||||
install -o root -cs $? $@
|
install -o root -cs $? $@
|
||||||
|
|
||||||
# clean up local files
|
# clean up local files
|
||||||
|
|
|
@ -109,22 +109,8 @@ FORWARD _PROTOTYPE( void prepare_output, (void) );
|
||||||
FORWARD _PROTOTYPE( void do_initialize, (void) );
|
FORWARD _PROTOTYPE( void do_initialize, (void) );
|
||||||
FORWARD _PROTOTYPE( void reply, (int code,int replyee,int proc,int status));
|
FORWARD _PROTOTYPE( void reply, (int code,int replyee,int proc,int status));
|
||||||
FORWARD _PROTOTYPE( void do_printer_output, (void) );
|
FORWARD _PROTOTYPE( void do_printer_output, (void) );
|
||||||
FORWARD _PROTOTYPE( void signal_handler, (int sig) );
|
FORWARD _PROTOTYPE( void do_signal, (message *m_ptr) );
|
||||||
|
|
||||||
/*===========================================================================*
|
|
||||||
* signal_handler *
|
|
||||||
*===========================================================================*/
|
|
||||||
PRIVATE void signal_handler(sig)
|
|
||||||
int sig; /* signal number */
|
|
||||||
{
|
|
||||||
/* Expect a SIGTERM signal when this server must shutdown. */
|
|
||||||
if (sig == SIGTERM) {
|
|
||||||
printf("Shutting down PRINTER driver\n");
|
|
||||||
exit(0);
|
|
||||||
} else {
|
|
||||||
printf("PRINTER got unknown signal\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* printer_task *
|
* printer_task *
|
||||||
|
@ -133,6 +119,14 @@ PUBLIC void main(void)
|
||||||
{
|
{
|
||||||
/* Main routine of the printer task. */
|
/* Main routine of the printer task. */
|
||||||
message pr_mess; /* buffer for all incoming messages */
|
message pr_mess; /* buffer for all incoming messages */
|
||||||
|
struct sigaction sa;
|
||||||
|
int s;
|
||||||
|
|
||||||
|
/* Install signal handlers. Ask PM to transform signal into message. */
|
||||||
|
sa.sa_handler = SIG_MESS;
|
||||||
|
sigemptyset(&sa.sa_mask);
|
||||||
|
sa.sa_flags = 0;
|
||||||
|
if (sigaction(SIGTERM,&sa,NULL)<0) panic("PRN","sigaction failed", errno);
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
receive(ANY, &pr_mess);
|
receive(ANY, &pr_mess);
|
||||||
|
@ -147,7 +141,7 @@ PUBLIC void main(void)
|
||||||
case DEV_STATUS: do_status(&pr_mess); break;
|
case DEV_STATUS: do_status(&pr_mess); break;
|
||||||
case CANCEL: do_cancel(&pr_mess); break;
|
case CANCEL: do_cancel(&pr_mess); break;
|
||||||
case HARD_INT: do_printer_output(); break;
|
case HARD_INT: do_printer_output(); break;
|
||||||
case SYS_SIG: /* do nothing */ break;
|
case SYS_SIG: do_signal(&pr_mess); break;
|
||||||
case DEV_PING: notify(pr_mess.m_source); break;
|
case DEV_PING: notify(pr_mess.m_source); break;
|
||||||
default:
|
default:
|
||||||
reply(TASK_REPLY, pr_mess.m_source, pr_mess.PROC_NR, EINVAL);
|
reply(TASK_REPLY, pr_mess.m_source, pr_mess.PROC_NR, EINVAL);
|
||||||
|
@ -155,6 +149,23 @@ PUBLIC void main(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*===========================================================================*
|
||||||
|
* do_signal *
|
||||||
|
*===========================================================================*/
|
||||||
|
PRIVATE void do_signal(m_ptr)
|
||||||
|
message *m_ptr; /* signal message */
|
||||||
|
{
|
||||||
|
int sig;
|
||||||
|
sigset_t sigset = m_ptr->NOTIFY_ARG;
|
||||||
|
|
||||||
|
/* Expect a SIGTERM signal when this server must shutdown. */
|
||||||
|
if (sigismember(&sigset, SIGTERM)) {
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
/* Ignore all other signals. */
|
||||||
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* do_write *
|
* do_write *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
|
@ -237,14 +248,9 @@ PRIVATE void output_done()
|
||||||
else { /* done! report back to FS */
|
else { /* done! report back to FS */
|
||||||
status = orig_count;
|
status = orig_count;
|
||||||
}
|
}
|
||||||
#if DEAD_CODE
|
|
||||||
reply(REVIVE, caller, proc_nr, status);
|
|
||||||
writing = FALSE;
|
|
||||||
#else
|
|
||||||
revive_pending = TRUE;
|
revive_pending = TRUE;
|
||||||
revive_status = status;
|
revive_status = status;
|
||||||
notify(caller);
|
notify(caller);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
|
@ -311,7 +317,6 @@ int status; /* number of chars printed or error code */
|
||||||
PRIVATE void do_initialize()
|
PRIVATE void do_initialize()
|
||||||
{
|
{
|
||||||
/* Set global variables and initialize the printer. */
|
/* Set global variables and initialize the printer. */
|
||||||
|
|
||||||
static int initialized = FALSE;
|
static int initialized = FALSE;
|
||||||
if (initialized) return;
|
if (initialized) return;
|
||||||
initialized = TRUE;
|
initialized = TRUE;
|
||||||
|
|
|
@ -163,7 +163,6 @@ PUBLIC void main(void)
|
||||||
message tty_mess; /* buffer for all incoming messages */
|
message tty_mess; /* buffer for all incoming messages */
|
||||||
unsigned line;
|
unsigned line;
|
||||||
int r, s;
|
int r, s;
|
||||||
char *types[] = {"task","driver","server", "user"};
|
|
||||||
register struct proc *rp;
|
register struct proc *rp;
|
||||||
register tty_t *tp;
|
register tty_t *tp;
|
||||||
|
|
||||||
|
@ -1506,7 +1505,7 @@ PRIVATE void tty_init()
|
||||||
|
|
||||||
register tty_t *tp;
|
register tty_t *tp;
|
||||||
int s;
|
int s;
|
||||||
struct sigaction sigact;
|
struct sigaction sa;
|
||||||
|
|
||||||
/* Initialize the terminal lines. */
|
/* Initialize the terminal lines. */
|
||||||
for (tp = FIRST_TTY,s=0; tp < END_TTY; tp++,s++) {
|
for (tp = FIRST_TTY,s=0; tp < END_TTY; tp++,s++) {
|
||||||
|
@ -1534,12 +1533,13 @@ PRIVATE void tty_init()
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEAD_CODE
|
#if DEAD_CODE
|
||||||
/* Install signal handler to ignore SIGTERM. */
|
/* Install signal handlers. Ask PM to transform signal into message. */
|
||||||
sigact.sa_handler = SIG_IGN;
|
sa.sa_handler = SIG_MESS;
|
||||||
sigact.sa_mask = ~0; /* block all other signals */
|
sigemptyset(&sa.sa_mask);
|
||||||
sigact.sa_flags = 0; /* default behaviour */
|
sa.sa_flags = 0;
|
||||||
if (sigaction(SIGTERM, &sigact, NULL) != OK)
|
if (sigaction(SIGTERM,&sa,NULL)<0) panic("TTY","sigaction failed", errno);
|
||||||
report("TTY","warning, sigaction() failed", errno);
|
if (sigaction(SIGKMESS,&sa,NULL)<0) panic("TTY","sigaction failed", errno);
|
||||||
|
if (sigaction(SIGKSTOP,&sa,NULL)<0) panic("TTY","sigaction failed", errno);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue