#include <h/mime.h>
#include <h/tws.h>
#include <h/utils.h>
+#include <sysexits.h>
+#include <sys/wait.h>
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#include <time.h>
int debugsw = 0; /* global */
-char *altmsg = NULL;
+char *altmsg = NULL;
char *annotext = NULL;
char *distfile = NULL;
static void clean_up_temporary_files(void);
static int get_line(void);
static void make_mime_composition_file_entry(char *);
+static char* strexit(int status);
static struct swit switches[] = {
fclose(composition_file);
/* We're ready to roll! */
- sprintf(buf, "mhbuild %s", composition_file_name);
- if (system(buf) != 0) {
+ if (execprogl("mhbuild", "mhbuild", composition_file_name,
+ (char *)NULL) != 0) {
/* some problem */
clean_up_temporary_files();
return (NOTOK);
char buf[BUFSIZ];
int dosign = 0;
int doenc = 0;
+ int ret;
if (!(draft_file = fopen(draft_file_name, "r"))) {
adios(NULL, "can't open draft file `%s'.", draft_file_name);
strcpy(composition_file_name, draft_file_name);
/* We're ready to roll! */
- sprintf(buf, "mhsign -m%s '%s'", doenc ? " -e" : "",
- draft_file_name);
- if (system(buf) != 0) {
+ if (doenc) {
+ ret = execprogl("mhsign", "mhsign", "-m", "-e",
+ draft_file_name, (char *)NULL);
+ } else {
+ ret = execprogl("mhsign", "mhsign", "-m",
+ draft_file_name, (char *)NULL);
+ }
+ if (ret != 0) {
/* some problem */
return (NOTOK);
}
default:
/* parent process -- wait for it */
- if ((status = pidwait(child_id, NOTOK)) == OK) {
+ status = pidwait(child_id, NOTOK);
+ if (WIFEXITED(status) && WEXITSTATUS(status) == EX_OK) {
if (annotext) {
anno(st);
}
} else {
/* spost failed */
- advise(NULL, "message not delivered to anyone");
+ advise(NULL, "%s", strexit(status));
if (distfile) {
unlink(drft);
if (rename(backup, drft) == NOTOK) {
}
}
}
- break;
}
+
return status;
}
}
+char*
+strexit(int status)
+{
+ if (WIFSIGNALED(status)) {
+ return "spost or sendmail killed by signal";
+ }
+ if (!WIFEXITED(status)) {
+ return "message not delivered to anyone";
+ }
+ switch (WEXITSTATUS(status)) {
+ case EX_TEMPFAIL:
+ return "Temporary error, maybe the MTA has queued the message";
+ default:
+ return "message not delivered to anyone";
+ }
+}
+
+
static void
armed_done(int status)
{