-/*
- * m_mktemp.c -- Construct a temporary file.
+/* m_mktemp.c -- Construct a temporary file.
*
* This code is Copyright (c) 2010, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
#include <h/mh.h>
#include <h/utils.h>
#include <h/signals.h>
+#include "m_maildir.h"
+#include "m_mktemp.h"
static void register_for_removal(const char *);
if (suffix == NULL) {
if ((tmpfil = m_mktemp2(NULL, pfx_in, fd_ret, fp_ret))) {
- return add(tmpfil, NULL);
- } else {
- return NULL;
+ return mh_xstrdup(tmpfil);
}
+ return NULL;
}
#if HAVE_MKSTEMPS
fd = mkstemps(tmpfil, (int) strlen(suffix));
#else /* ! HAVE_MKSTEMPS */
- /* Solaris 10, e.g. */
+ /* NetBSD, Solaris 10 */
if (pfx_in == NULL) {
tmpfil = concat(get_temp_dir(), "/nmhXXXXXX", NULL);
char *
-get_temp_dir()
+get_temp_dir(void)
{
/* Ignore envvars if we are setuid */
if ((getuid()==geteuid()) && (getgid()==getegid())) {
* Remove all registered temporary files.
*/
void
-remove_registered_files_atexit() {
+remove_registered_files_atexit(void) {
unregister_for_removal(1);
}
exit(1);
} else {
+ remove_registered_files_atexit();
+
act.sa_handler = SIG_DFL;
(void) sigemptyset(&act.sa_mask);
act.sa_flags = 0;
(void) sigaction(sig, &act, 0);
- remove_registered_files_atexit();
-
(void) raise(sig);
}
}