]> diplodocus.org Git - nmh/blobdiff - uip/rcvtty.c
Disable assertions by default.
[nmh] / uip / rcvtty.c
index 9cd77dd6e37bb37241efd38a8455d1f02fb660be..356234adf3062a5f68ffb603412a76e233ecc9d2 100644 (file)
@@ -19,7 +19,6 @@
 #include <h/scansbr.h>
 #include <h/tws.h>
 #include <h/mts.h>
-#include <signal.h>
 #include <fcntl.h>
 
 #ifdef HAVE_GETUTXENT
@@ -70,7 +69,9 @@ char *getusername(void);
 static void alrmser (int);
 static int message_fd (char **);
 static int header_fd (void);
+#if HAVE_GETUTXENT
 static void alert (char *, int);
+#endif /* HAVE_GETUTXENT */
 
 
 int
@@ -165,10 +166,12 @@ main (int argc, char **argv)
         }
     }
     endutxent();
+#else
+    NMH_UNUSED (tty);
+    NMH_UNUSED (utp);
 #endif /* HAVE_GETUTXENT */
 
     exit (RCV_MOK);
-    return 0;  /* dead code to satisfy the compiler */
 }
 
 
@@ -185,14 +188,16 @@ static int
 message_fd (char **vec)
 {
     pid_t child_id;
-    int bytes, fd, seconds;
+    int bytes, seconds;
+    /* volatile to prevent "might be clobbered" warning from gcc: */
+    volatile int fd;
     char tmpfil[BUFSIZ];
     struct stat st;
 
     fd = mkstemp (strncpy (tmpfil, "/tmp/rcvttyXXXXX", sizeof(tmpfil)));
     unlink (tmpfil);
 
-    if ((child_id = vfork()) == NOTOK) {
+    if ((child_id = fork()) == NOTOK) {
        /* fork error */
        close (fd);
        return header_fd ();
@@ -235,9 +240,11 @@ message_fd (char **vec)
        _exit (-1);
     closefds (3);
     setpgid ((pid_t) 0, getpid ());    /* put in own process group */
-    execvp (vec[0], vec);
-    _exit (-1);
-    return 1;  /* dead code to satisfy compiler */
+    if (execvp (vec[0], vec) == NOTOK) {
+        _exit (-1);
+    }
+
+    return NOTOK;
 }
 
 
@@ -257,6 +264,7 @@ header_fd (void)
     /* get new format string */
     nfs = new_fs (form, format, SCANFMT);
     scan (stdin, 0, 0, nfs, width, 0, 0, NULL, 0L, 0);
+    scan_finished ();
     if (newline)
         write (fd, "\n\r", 2);
     write (fd, scanl, strlen (scanl));
@@ -267,6 +275,7 @@ header_fd (void)
 }
 
 
+#if HAVE_GETUTXENT
 static void
 alert (char *tty, int md)
 {
@@ -304,4 +313,4 @@ alert (char *tty, int md)
 
     close (td);
 }
-
+#endif /* HAVE_GETUTXENT */