start up cleanly
authorSam Leffler <sam@ucbvax.Berkeley.EDU>
Mon, 11 Oct 1982 08:35:30 +0000 (00:35 -0800)
committerSam Leffler <sam@ucbvax.Berkeley.EDU>
Mon, 11 Oct 1982 08:35:30 +0000 (00:35 -0800)
SCCS-vsn: libexec/telnetd/telnetd.c 4.9
SCCS-vsn: old/implogd/implogd.c 4.2

usr/src/libexec/telnetd/telnetd.c
usr/src/old/implogd/implogd.c

index b52d35d..abc2ec1 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)telnetd.c  4.8 82/10/07";
+static char sccsid[] = "@(#)telnetd.c  4.9 82/10/10";
 #endif
 
 /*
 #endif
 
 /*
@@ -68,6 +68,21 @@ main(argc, argv)
                }
        }
        sin.sin_port = htons(sin.sin_port);
                }
        }
        sin.sin_port = htons(sin.sin_port);
+#ifndef DEBUG
+       if (fork())
+               exit(0);
+       for (s = 0; s < 10; s++)
+               (void) close(s);
+       (void) open("/", 0);
+       (void) dup2(0, 1);
+       (void) dup2(0, 2);
+       { int tt = open("/dev/tty", 2);
+         if (tt > 0) {
+               ioctl(tt, TIOCNOTTY, 0);
+               close(tt);
+         }
+       }
+#endif
        for (;;) {
                errno = 0;
                if ((s = socket(SOCK_STREAM, 0, &sin, options)) < 0) {
        for (;;) {
                errno = 0;
                if ((s = socket(SOCK_STREAM, 0, &sin, options)) < 0) {
index 7f8d007..aaedb2a 100644 (file)
@@ -1,4 +1,4 @@
-/*     implogd.c       4.1     82/04/04        */
+/*     implogd.c       4.2     82/10/10        */
 
 #include <time.h>
 #include <sgtty.h>
 
 #include <time.h>
 #include <sgtty.h>
@@ -40,11 +40,21 @@ main(argc, argv)
        argc--, argv++;
        if (argc > 0 && !strcmp(argv[0], "-d"))
                options |= SO_DEBUG;
        argc--, argv++;
        if (argc > 0 && !strcmp(argv[0], "-d"))
                options |= SO_DEBUG;
-       s = open("/dev/tty", 2);
-       if (s >= 0) {
-               ioctl(s, TIOCNOTTY, 0);
-               close(s);
+#ifndef DEBUG
+       if (fork())
+               exit(0);
+       for (s = 0; s < 10; s++)
+               (void) close(t);
+       (void) open("/", 0);
+       (void) dup2(0, 1);
+       (void) dup2(0, 2);
+       { int tt = open("/dev/tty", 2);
+         if (tt > 0) {
+               ioctl(tt, TIOCNOTTY, 0);
+               close(tt);
+         }
        }
        }
+#endif
        log = open(LOGFILE, 1);
        if (log < 0)
                exit(1);
        log = open(LOGFILE, 1);
        if (log < 0)
                exit(1);