cleanups, add manual page
[unix-history] / usr / src / usr.bin / mail / main.c
index cdcf644..fa89893 100644 (file)
@@ -22,7 +22,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     5.16 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c     5.19 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "rcv.h"
 #endif /* not lint */
 
 #include "rcv.h"
@@ -43,16 +43,18 @@ main(argc, argv)
        struct name *to, *cc, *bcc, *smopts;
        char *subject;
        char *ef;
        struct name *to, *cc, *bcc, *smopts;
        char *subject;
        char *ef;
+       char nosrc = 0;
        int hdrstop(), (*prevint)();
        int hdrstop(), (*prevint)();
+       int sigchild();
        extern int getopt(), optind, opterr;
        extern char *optarg;
 
        /*
         * Set up a reasonable environment.
        extern int getopt(), optind, opterr;
        extern char *optarg;
 
        /*
         * Set up a reasonable environment.
-        * Figure out whether we are being run interactively, set up
-        * all the temporary files, buffer standard output, and so forth.
+        * Figure out whether we are being run interactively,
+        * start the SIGCHLD catcher, and so forth.
         */
         */
-       mypid = getpid();
+       (void) signal(SIGCHLD, sigchild);
        if (isatty(0))
                assign("interactive", "");
        image = -1;
        if (isatty(0))
                assign("interactive", "");
        image = -1;
@@ -87,7 +89,7 @@ main(argc, argv)
                        /*
                         * Next argument is person to pretend to be.
                         */
                        /*
                         * Next argument is person to pretend to be.
                         */
-                       strcpy(myname, optarg);
+                       myname = optarg;
                        break;
                case 'i':
                        /*
                        break;
                case 'i':
                        /*
@@ -186,9 +188,14 @@ Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...\n\
        setscreensize();
        input = stdin;
        rcvmode = !to;
        setscreensize();
        input = stdin;
        rcvmode = !to;
+       spreserve();
        if (!nosrc)
                load(MASTER);
        if (!nosrc)
                load(MASTER);
-       load(mailrc);
+       /*
+        * Expand returns a savestr, but load only uses the file name
+        * for fopen, so it's save to do this.
+        */
+       load(expand("~/.mailrc"));
        if (!rcvmode) {
                mail(to, cc, bcc, smopts, subject);
                /*
        if (!rcvmode) {
                mail(to, cc, bcc, smopts, subject);
                /*