Harald Geyer: back out fork/vfork workaround and handle the issue directly
authorOliver Kiddle <okiddle@yahoo.co.uk>
Wed, 5 Oct 2005 10:05:24 +0000 (10:05 +0000)
committerOliver Kiddle <okiddle@yahoo.co.uk>
Wed, 5 Oct 2005 10:05:24 +0000 (10:05 +0000)
ChangeLog
h/mh.h
uip/replsbr.c

index 218fcf1..7dfebbb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-10-05  Oliver Kiddle  <okiddle@yahoo.co.uk>
+
+       * Harald Geyer: h/mh.h, uip/replsbr.c: back out previous change
+       (fork/vfork) and replace with code that handles the issue directly
+
 2005-05-18  Oliver Kiddle  <okiddle@yahoo.co.uk>
 
        * Debian Bug# 143485: Nick Rusnov: h/mh.h: use fork instead of
 2005-05-18  Oliver Kiddle  <okiddle@yahoo.co.uk>
 
        * Debian Bug# 143485: Nick Rusnov: h/mh.h: use fork instead of
diff --git a/h/mh.h b/h/mh.h
index afe2682..81a6021 100644 (file)
--- a/h/mh.h
+++ b/h/mh.h
@@ -7,15 +7,6 @@
 
 #include <h/nmh.h>
 
 
 #include <h/nmh.h>
 
-/* A quick fix for Linux systems. According to the vfork manual page, 
-   there is little difference in performance, so we aren't losing much.
-   But this fixes a minor message bug so why not? On NetBSD, this should
-   probably not happen. */
-#ifdef linux
-#define vfork fork
-#endif
-
-
 /*
  * Well-used constants
  */
 /*
  * Well-used constants
  */
index 4b2b30d..0b0ba6e 100644 (file)
@@ -13,6 +13,7 @@
 #include <h/addrsbr.h>
 #include <h/fmt_scan.h>
 #include <sys/file.h>          /* L_SET */
 #include <h/addrsbr.h>
 #include <h/fmt_scan.h>
 #include <sys/file.h>          /* L_SET */
+#include <errno.h>
 
 extern short ccto;             /* from repl.c */
 extern short cccc;
 
 extern short ccto;             /* from repl.c */
 extern short cccc;
@@ -247,6 +248,10 @@ finished:
      * or add mhn directives
      */
     if (filter) {
      * or add mhn directives
      */
     if (filter) {
+       fflush(out);
+       if (ferror (out))
+           adios (drft, "error writing");
+       
        replfilter (inb, out, filter);
     } else if (mime && mp) {
            fprintf (out, "#forw [original message] +%s %s\n",
        replfilter (inb, out, filter);
     } else if (mime && mp) {
            fprintf (out, "#forw [original message] +%s %s\n",
@@ -413,6 +418,8 @@ insert (struct mailname *np)
 
 /*
  * Call the mhlproc
 
 /*
  * Call the mhlproc
+ *
+ * This function expects that argument out has been fflushed by the caller.
  */
 
 static void
  */
 
 static void
@@ -420,6 +427,7 @@ replfilter (FILE *in, FILE *out, char *filter)
 {
     int        pid;
     char *mhl;
 {
     int        pid;
     char *mhl;
+    char *errstr;
 
     if (filter == NULL)
        return;
 
     if (filter == NULL)
        return;
@@ -431,7 +439,6 @@ replfilter (FILE *in, FILE *out, char *filter)
 
     rewind (in);
     lseek (fileno(in), (off_t) 0, SEEK_SET);
 
     rewind (in);
     lseek (fileno(in), (off_t) 0, SEEK_SET);
-    fflush (out);
 
     switch (pid = vfork ()) {
        case NOTOK: 
 
     switch (pid = vfork ()) {
        case NOTOK: 
@@ -443,8 +450,12 @@ replfilter (FILE *in, FILE *out, char *filter)
            closefds (3);
 
            execlp (mhlproc, mhl, "-form", filter, "-noclear", NULL);
            closefds (3);
 
            execlp (mhlproc, mhl, "-form", filter, "-noclear", NULL);
-           fprintf (stderr, "unable to exec ");
-           perror (mhlproc);
+           errstr = strerror(errno);
+           write(2, "unable to exec ", 15);
+           write(2, mhlproc, strlen(mhlproc));
+           write(2, ": ", 2);
+           write(2, errstr, strlen(errstr));
+           write(2, "\n", 1);
            _exit (-1);
 
        default: 
            _exit (-1);
 
        default: