X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=uip%2Fmhmail.c;h=990776ca12dc1cbd6a4a5ac9713b7e85388e343c;hb=a2469f5ecbca3a179251ac9b777b561bc5245d4c;hp=d74a7f1d4b4f8b1302912e8c318454d310c5322e;hpb=6c42153ad9362cc676ea66563bf400d7511b3b68;p=mmh diff --git a/uip/mhmail.c b/uip/mhmail.c index d74a7f1..990776c 100644 --- a/uip/mhmail.c +++ b/uip/mhmail.c @@ -2,8 +2,6 @@ /* * mhmail.c -- simple mail program * - * $Id$ - * * This code is Copyright (c) 2002, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for * complete copyright information. @@ -11,6 +9,7 @@ #include #include +#include #include static struct swit switches[] = { @@ -38,7 +37,7 @@ static char tmpfil[BUFSIZ]; /* * static prototypes */ -static RETSIGTYPE intrser (int); +static void intrser (int); int @@ -51,6 +50,7 @@ main (int argc, char **argv) char *from = NULL, *body = NULL, **argp, **arguments; char *vec[5], buf[BUFSIZ]; FILE *out; + char *tfile = NULL; #ifdef LOCALE setlocale(LC_ALL, ""); @@ -124,10 +124,11 @@ main (int argc, char **argv) if (tolist == NULL) adios (NULL, "usage: %s addrs ... [switches]", invo_name); - strncpy (tmpfil, m_tmpfil (invo_name), sizeof(tmpfil)); - if ((out = fopen (tmpfil, "w")) == NULL) - adios (tmpfil, "unable to write"); - chmod (tmpfil, 0600); + + tfile = m_mktemp2(NULL, invo_name, NULL, &out); + if (tfile == NULL) adios("mhmail", "unable to create temporary file"); + chmod(tfile, 0600); + strncpy (tmpfil, tfile, sizeof(tmpfil)); SIGNAL2 (SIGINT, intrser); @@ -172,7 +173,7 @@ main (int argc, char **argv) if (child_id == NOTOK) { /* report failure and then send it */ - admonish (NULL, "unable to fork"); + adios (NULL, "unable to fork"); } else if (child_id) { /* parent process */ if ((status = pidXwait(child_id, postproc))) { @@ -196,14 +197,9 @@ main (int argc, char **argv) } -static RETSIGTYPE +static void intrser (int i) { -#ifndef RELIABLE_SIGNALS - if (i) - SIGNAL (i, SIG_IGN); -#endif - unlink (tmpfil); done (i != 0 ? 1 : 0); }