rationalized handling of child processes, cleaned up mail1 some more
[unix-history] / usr / src / usr.bin / mail / cmd1.c
index 7c970d8..825da0d 100644 (file)
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)cmd1.c     5.11 (Berkeley) %G%";
+static char sccsid[] = "@(#)cmd1.c     5.15 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "rcv.h"
 #endif /* not lint */
 
 #include "rcv.h"
-#include <sys/stat.h>
-#include <sys/wait.h>
 
 /*
  * Mail -- a mail program
 
 /*
  * Mail -- a mail program
@@ -65,7 +63,6 @@ headers(msgvec)
                if (flag++ >= size)
                        break;
                printhead(mesg);
                if (flag++ >= size)
                        break;
                printhead(mesg);
-               sreset();
        }
        if (flag == 0) {
                printf("No more mail.\n");
        }
        if (flag == 0) {
                printf("No more mail.\n");
@@ -74,40 +71,9 @@ headers(msgvec)
        return(0);
 }
 
        return(0);
 }
 
-/*
- * Set the list of alternate names for out host.
- */
-local(namelist)
-       char **namelist;
-{
-       register int c;
-       register char **ap, **ap2, *cp;
-
-       c = argcount(namelist) + 1;
-       if (c == 1) {
-               if (localnames == 0)
-                       return(0);
-               for (ap = localnames; *ap; ap++)
-                       printf("%s ", *ap);
-               printf("\n");
-               return(0);
-       }
-       if (localnames != 0)
-               cfree((char *) localnames);
-       localnames = (char **) calloc((unsigned) c, sizeof (char *));
-       for (ap = namelist, ap2 = localnames; *ap; ap++, ap2++) {
-               cp = (char *) calloc((unsigned) strlen(*ap) + 1, sizeof (char));
-               strcpy(cp, *ap);
-               *ap2 = cp;
-       }
-       *ap2 = 0;
-       return(0);
-}
-
 /*
  * Scroll to the next/previous screen
  */
 /*
  * Scroll to the next/previous screen
  */
-
 scroll(arg)
        char arg[];
 {
 scroll(arg)
        char arg[];
 {
@@ -166,10 +132,8 @@ from(msgvec)
 {
        register int *ip;
 
 {
        register int *ip;
 
-       for (ip = msgvec; *ip != NULL; ip++) {
+       for (ip = msgvec; *ip != NULL; ip++)
                printhead(*ip);
                printhead(*ip);
-               sreset();
-       }
        if (--ip >= msgvec)
                dot = &message[*ip - 1];
        return(0);
        if (--ip >= msgvec)
                dot = &message[*ip - 1];
        return(0);
@@ -346,7 +310,7 @@ type1(msgvec, doign, page)
                dot = mp;
                if (value("quiet") == NOSTR)
                        fprintf(obuf, "Message %d:\n", mesg);
                dot = mp;
                if (value("quiet") == NOSTR)
                        fprintf(obuf, "Message %d:\n", mesg);
-               send(mp, obuf, doign ? ignore : 0);
+               (void) send(mp, obuf, doign ? ignore : 0, NOSTR);
        }
        if (obuf != stdout) {
                pipef = NULL;
        }
        if (obuf != stdout) {
                pipef = NULL;
@@ -452,25 +416,14 @@ mboxit(msgvec)
 folders()
 {
        char dirname[BUFSIZ];
 folders()
 {
        char dirname[BUFSIZ];
-       int pid, e;
-       union wait s;
+       char *cmd;
 
        if (getfold(dirname) < 0) {
                printf("No value set for \"folder\"\n");
 
        if (getfold(dirname) < 0) {
                printf("No value set for \"folder\"\n");
-               return(-1);
+               return -1;
        }
        }
-       switch ((pid = fork())) {
-       case 0:
-               execlp("ls", "ls", dirname, 0);
-               _exit(1);
-
-       case -1:
-               perror("fork");
-               return(-1);
-
-       default:
-               while ((e = wait(&s)) != -1 && e != pid)
-                       ;
-       }
-       return(0);
+       if ((cmd = value("LISTER")) == NOSTR)
+               cmd = "ls";
+       (void) run_command(cmd, 0, -1, -1, dirname, NOSTR);
+       return 0;
 }
 }