diff options
Diffstat (limited to 'init')
-rw-r--r-- | init/ChangeLog | 21 | ||||
-rw-r--r-- | init/init.c | 85 |
2 files changed, 80 insertions, 26 deletions
diff --git a/init/ChangeLog b/init/ChangeLog index 5e1d8a2b..09c325bb 100644 --- a/init/ChangeLog +++ b/init/ChangeLog @@ -1,3 +1,24 @@ +Mon Aug 12 11:12:22 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> + + * init.c (setup_terminal): Declare LINE. + (add_terminal): Don't declare LINE. + +Thu Aug 8 16:34:06 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> + + * init.c (setup_terminal): New function. + (add_terminal): Use setup_terminal. + (reread_ttys): When turning an existent terminal spec on, call + setup_terminal before startup_terminal. + + * init.c (struct terminal): New member `read'. + (shutdown_terminal): New function. + (reread_ttys): Use shutdown_terminal instead of doing it by hand. + Keep track of which ttys we used to know about are no longer in + /etc/ttys, and treat them as now `off'. + + * init.c (kill_everyone): `continue' in the essential task case + didn't go back to the main loop; fix it up correctly. + Tue Jul 16 11:55:09 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu> * init.c (process_signal): Set WUNTRACED in call to waitpid. diff --git a/init/init.c b/init/init.c index 58a33410..40d96a6f 100644 --- a/init/init.c +++ b/init/init.c @@ -113,6 +113,7 @@ struct terminal int on; int pid; + int read; char *name; }; @@ -474,13 +475,38 @@ run_for_real (char *filename, char *args, int arglen, mach_port_t ctty, /** /etc/ttys support **/ +/* Set up the getty and window fields of terminal spec T corresponding + to line TT. */ +void +setup_terminal (struct terminal *t, struct ttyent *tt) +{ + char *line; + + if (t->getty_argz) + free (t->getty_argz); + if (t->window_argz) + free (t->window_argz); + + if ((tt->ty_status & TTY_ON) && tt->ty_getty) + { + asprintf (&line, "%s %s", tt->ty_getty, tt->ty_name); + argz_create_sep (line, ' ', &t->getty_argz, &t->getty_argz_len); + if (tt->ty_window) + argz_create_sep (tt->ty_window, ' ', + &t->window_argz, &t->window_argz_len); + else + t->window_argz = 0; + } + else + t->getty_argz = t->window_argz = 0; +} + /* Add a new terminal spec for TT and return it. */ struct terminal * add_terminal (struct ttyent *tt) { struct terminal *t; - char *line; if (nttys >= ttyslen) { @@ -495,30 +521,12 @@ add_terminal (struct ttyent *tt) t->name = malloc (strlen (tt->ty_name) + 1); strcpy (t->name, tt->ty_name); + setup_terminal (t, tt); if (t->getty_argz) - free (t->getty_argz); - if (t->window_argz) - free (t->window_argz); + t->on = 1; - if ((tt->ty_status & TTY_ON) && tt->ty_getty) - { - asprintf (&line, "%s %s", tt->ty_getty, tt->ty_name); - argz_create_sep (line, ' ', &t->getty_argz, &t->getty_argz_len); - if (tt->ty_window) - argz_create_sep (tt->ty_window, ' ', - &t->window_argz, &t->window_argz_len); - else - t->window_argz = 0; - t->on = 1; - } - else - { - t->getty_argz = t->window_argz = 0; - t->on = 0; - } return t; } - /* Read /etc/ttys and initialize ttys array. Return non-zero if we fail. */ int @@ -649,22 +657,34 @@ restart_terminal (int pid) } } +/* Shutdown the things running on terminal spec T. */ +void +shutdown_terminal (struct terminal *t) +{ + kill (t->pid, SIGHUP); + /* revoke?? */; +} + /* Re-read /etc/ttys. If a line has turned off, kill what's there. - If a line has turned on, start it. If an on line has changed, - kill it, and then restart it. */ + If a line has turned on, start it. */ void reread_ttys (void) { struct ttyent *tt; struct terminal *t; int on; - + int i; + if (!setttyent ()) { error (0, errno, "%s", _PATH_TTYS); return; } + /* Mark all the lines not yet read */ + for (i = 0; i < nttys; i++) + ttys[i].read = 0; + while ((tt = getttyent ())) { if (!tt->ty_name) @@ -678,11 +698,12 @@ reread_ttys (void) if (t->on && !on) { t->on = 0; - kill (t->pid, SIGHUP); + shutdown_terminal (t); } else if (!t->on && on) { t->on = 1; + setup_terminal (t, tt); startup_terminal (t); } } @@ -692,8 +713,18 @@ reread_ttys (void) if (on) startup_terminal (t); } + + t->read = 1; } endttyent (); + + /* Scan tty entries; any that were not found and were on, turn off. */ + for (i = 0; i < nttys; i++) + if (!ttys[i].read && ttys[i].on) + { + ttys[i].on = 0; + shutdown_terminal (&ttys[i]); + } } @@ -1213,8 +1244,10 @@ kill_everyone (int signo) { /* Skip this one */ mach_port_deallocate (mach_task_self (), tk); - continue; + break; } + if (es) + continue; /* Kill it */ if (signo == SIGKILL) |