declare merege() externally, ANSI C fix
[unix-history] / usr / src / sbin / init / init.c
index d8aa178..8765e27 100644 (file)
@@ -1,11 +1,11 @@
 /*
 /*
- * Copyright (c) 1980 Regents of the University of California.
+ * Copyright (c) 1980,1986 Regents of the University of California.
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  */
 
 #ifndef lint
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)init.c     5.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)init.c     5.10 (Berkeley) %G%";
 #endif not lint
 
 #include <signal.h>
 #endif not lint
 
 #include <signal.h>
@@ -16,11 +16,11 @@ static char sccsid[] = "@(#)init.c  5.3 (Berkeley) %G%";
 #include <errno.h>
 #include <sys/file.h>
 #include <ttyent.h>
 #include <errno.h>
 #include <sys/file.h>
 #include <ttyent.h>
-#include <syslog.h>
+#include <sys/syslog.h>
 #include <sys/stat.h>
 
 #define        LINSIZ  sizeof(wtmp.ut_line)
 #include <sys/stat.h>
 
 #define        LINSIZ  sizeof(wtmp.ut_line)
-#define        CMDSIZ  70      /* max string length for getty or window command*/
+#define        CMDSIZ  200     /* max string length for getty or window command*/
 #define        ALL     p = itab; p ; p = p->next
 #define        EVER    ;;
 #define SCPYN(a, b)    strncpy(a, b, sizeof(a))
 #define        ALL     p = itab; p ; p = p->next
 #define        EVER    ;;
 #define SCPYN(a, b)    strncpy(a, b, sizeof(a))
@@ -63,9 +63,12 @@ long lseek();
 struct sigvec rvec = { reset, sigmask(SIGHUP), 0 };
 
 
 struct sigvec rvec = { reset, sigmask(SIGHUP), 0 };
 
 
-#ifdef vax
+#if defined(vax) || defined(tahoe)
 main()
 {
 main()
 {
+#if defined(tahoe)
+       register int r12;               /* make sure r11 gets bootflags */
+#endif
        register int r11;               /* passed thru from boot */
 #else
 main(argc, argv)
        register int r11;               /* passed thru from boot */
 #else
 main(argc, argv)
@@ -75,7 +78,7 @@ main(argc, argv)
        int howto, oldhowto;
 
        time0 = time(0);
        int howto, oldhowto;
 
        time0 = time(0);
-#ifdef vax
+#if defined(vax) || defined(tahoe)
        howto = r11;
 #else
        if (argc > 1 && argv[1][0] == '-') {
        howto = r11;
 #else
        if (argc > 1 && argv[1][0] == '-') {
@@ -95,7 +98,7 @@ main(argc, argv)
                howto = RB_SINGLE;
        }
 #endif
                howto = RB_SINGLE;
        }
 #endif
-       openlog("init", LOG_CONS|LOG_ODELAY, 0);
+       openlog("init", LOG_CONS|LOG_ODELAY, LOG_AUTH);
        sigvec(SIGTERM, &rvec, (struct sigvec *)0);
        signal(SIGTSTP, idle);
        signal(SIGSTOP, SIG_IGN);
        sigvec(SIGTERM, &rvec, (struct sigvec *)0);
        signal(SIGTSTP, idle);
        signal(SIGSTOP, SIG_IGN);
@@ -133,6 +136,8 @@ shutdown()
        }
        itab = (struct tab *)0;
        signal(SIGALRM, shutreset);
        }
        itab = (struct tab *)0;
        signal(SIGALRM, shutreset);
+       (void) kill(-1, SIGTERM);       /* one chance to catch it */
+       sleep(5);
        alarm(30);
        for (i = 0; i < 5; i++)
                kill(-1, SIGKILL);
        alarm(30);
        for (i = 0; i < 5; i++)
                kill(-1, SIGKILL);
@@ -142,7 +147,7 @@ shutdown()
        shutend();
 }
 
        shutend();
 }
 
-char shutfailm[] = "WARNING: Something is hung (wont die); ps axl advised\n";
+char shutfailm[] = "WARNING: Something is hung (won't die); ps axl advised\n";
 
 shutreset()
 {
 
 shutreset()
 {
@@ -196,6 +201,7 @@ single()
                        dup2(0, 1);
                        dup2(0, 2);
                        execl(shell, minus, (char *)0);
                        dup2(0, 1);
                        dup2(0, 2);
                        execl(shell, minus, (char *)0);
+                       perror(shell);
                        exit(0);
                }
                while ((xpid = wait((int *)0)) != pid)
                        exit(0);
                }
                while ((xpid = wait((int *)0)) != pid)
@@ -258,7 +264,7 @@ multiple()
                pid = wait((int *)0);
                if (pid == -1)
                        return;
                pid = wait((int *)0);
                if (pid == -1)
                        return;
-               omask = sigblock(SIGHUP);
+               omask = sigblock(sigmask(SIGHUP));
                for (ALL) {
                        /* must restart window system BEFORE emulator */
                        if (p->wpid == pid || p->wpid == -1)
                for (ALL) {
                        /* must restart window system BEFORE emulator */
                        if (p->wpid == pid || p->wpid == -1)
@@ -304,7 +310,7 @@ merge()
                                p->xflag |= CHANGE;
                                SCPYN(p->comn, t->ty_getty);
                        }
                                p->xflag |= CHANGE;
                                SCPYN(p->comn, t->ty_getty);
                        }
-                       if (SCMPN(p->wcmd, t->ty_window)) {
+                       if (SCMPN(p->wcmd, t->ty_window ? t->ty_window : "")) {
                                p->xflag |= WCHANGE|CHANGE;
                                SCPYN(p->wcmd, t->ty_window);
                        }
                                p->xflag |= WCHANGE|CHANGE;
                                SCPYN(p->wcmd, t->ty_window);
                        }
@@ -333,7 +339,7 @@ merge()
                SCPYN(p->line, t->ty_name);
                p->xflag |= FOUND|CHANGE;
                SCPYN(p->comn, t->ty_getty);
                SCPYN(p->line, t->ty_name);
                p->xflag |= FOUND|CHANGE;
                SCPYN(p->comn, t->ty_getty);
-               if (strcmp(t->ty_window, "") != 0) {
+               if (t->ty_window && strcmp(t->ty_window, "") != 0) {
                        p->xflag |= WCHANGE;
                        SCPYN(p->wcmd, t->ty_window);
                }
                        p->xflag |= WCHANGE;
                        SCPYN(p->wcmd, t->ty_window);
                }
@@ -381,8 +387,6 @@ term(p)
                kill(p->wpid, SIGHUP);
 }
 
                kill(p->wpid, SIGHUP);
 }
 
-#include <sys/ioctl.h>
-
 dfork(p)
        struct tab *p;
 {
 dfork(p)
        struct tab *p;
 {
@@ -446,8 +450,8 @@ rmut(p)
                        nutmp = read(f, utmp, statbf.st_size);
                        nutmp /= sizeof(struct utmp);
                        for (u = utmp ; u < &utmp[nutmp] ; u++) {
                        nutmp = read(f, utmp, statbf.st_size);
                        nutmp /= sizeof(struct utmp);
                        for (u = utmp ; u < &utmp[nutmp] ; u++) {
-                               if (SCMPN(u->ut_line, p->line) ||
-                                   u->ut_name[0]==0)
+                               if (u->ut_name[0] == 0 ||
+                                   SCMPN(u->ut_line, p->line))
                                        continue;
                                lseek(f, ((long)u)-((long)utmp), L_SET);
                                SCPYN(u->ut_name, "");
                                        continue;
                                lseek(f, ((long)u)-((long)utmp), L_SET);
                                SCPYN(u->ut_name, "");