Update copyright year in (most) files (those that my script finds).
[exim.git] / src / src / transports / pipe.c
index 43d0e58959aa286c16eadc91c2bdf2cb0b8ba5be..cedce6fd926f93678d7a514c618a9f21b52c1462 100644 (file)
@@ -1,10 +1,10 @@
-/* $Cambridge: exim/src/src/transports/pipe.c,v 1.5 2005/05/03 14:20:01 ph10 Exp $ */
+/* $Cambridge: exim/src/src/transports/pipe.c,v 1.9 2006/02/07 11:19:03 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
-/* Copyright (c) University of Cambridge 1995 - 2005 */
+/* Copyright (c) University of Cambridge 1995 - 2006 */
 /* See the file NOTICE for conditions of use and distribution. */
 
 
@@ -89,7 +89,7 @@ pipe_transport_options_block pipe_transport_option_defaults = {
   NULL,           /* cmd */
   NULL,           /* allow_commands */
   NULL,           /* environment */
-  US"/usr/bin",   /* path */
+  US"/bin:/usr/bin",  /* path */
   NULL,           /* message_prefix (reset in init if not bsmtp) */
   NULL,           /* message_suffix (ditto) */
   US mac_expanded_string(EX_TEMPFAIL) ":"    /* temp_errors */
@@ -640,8 +640,8 @@ if ((outpid = fork()) < 0)
   addr->message = string_sprintf(
     "Failed to create process for handling output in %s transport",
       tblock->name);
-  close(fd_in);
-  close(fd_out);
+  (void)close(fd_in);
+  (void)close(fd_out);
   return FALSE;
   }
 
@@ -654,7 +654,7 @@ the subprocess to fail. */
 if (outpid == 0)
   {
   int count = 0;
-  close(fd_in);
+  (void)close(fd_in);
   set_process_info("reading output from |%s", cmd);
   while ((rc = read(fd_out, big_buffer, big_buffer_size)) > 0)
     {
@@ -671,11 +671,11 @@ if (outpid == 0)
       break;
       }
     }
-  close(fd_out);
+  (void)close(fd_out);
   _exit(0);
   }
 
-close(fd_out);  /* Not used in this process */
+(void)close(fd_out);  /* Not used in this process */
 
 
 /* Carrying on now with the main parent process. Attempt to write the message
@@ -830,6 +830,9 @@ above timed out. */
 
 if ((rc = child_close(pid, timeout)) != 0)
   {
+  uschar *tmsg = (addr->message == NULL)? US"" :
+    string_sprintf(" (preceded by %s)", addr->message);
+
   /* The process did not complete in time; kill its process group and fail
   the delivery. It appears to be necessary to kill the output process too, as
   otherwise it hangs on for some time if the actual pipe process is sleeping.
@@ -841,7 +844,7 @@ if ((rc = child_close(pid, timeout)) != 0)
     killpg(pid, SIGKILL);
     kill(outpid, SIGKILL);
     addr->transport_return = ob->timeout_defer? DEFER : FAIL;
-    addr->message = string_sprintf("pipe delivery process timed out");
+    addr->message = string_sprintf("pipe delivery process timed out%s", tmsg);
     }
 
   /* Wait() failed. */
@@ -850,7 +853,7 @@ if ((rc = child_close(pid, timeout)) != 0)
     {
     addr->transport_return = PANIC;
     addr->message = string_sprintf("Wait() failed for child process of %s "
-      "transport: %s", tblock->name, strerror(errno));
+      "transport: %s%s", tblock->name, strerror(errno), tmsg);
     }
 
   /* Either the process completed, but yielded a non-zero (necessarily
@@ -864,8 +867,8 @@ if ((rc = child_close(pid, timeout)) != 0)
       {
       addr->transport_return = FAIL;
       addr->message = string_sprintf("Child process of %s transport (running "
-        "command \"%s\") was terminated by signal %d (%s)", tblock->name, cmd,
-        -rc, os_strsignal(-rc));
+        "command \"%s\") was terminated by signal %d (%s)%s", tblock->name, cmd,
+        -rc, os_strsignal(-rc), tmsg);
       }
     }
 
@@ -917,8 +920,8 @@ if ((rc = child_close(pid, timeout)) != 0)
       {
       addr->transport_return = DEFER;
       addr->special_action = SPECIAL_FREEZE;
-      addr->message = string_sprintf("pipe process failed to exec \"%s\"",
-        cmd);
+      addr->message = string_sprintf("pipe process failed to exec \"%s\"%s",
+        cmd, tmsg);
       }
 
     /* Otherwise take action only if not ignoring status */
@@ -992,6 +995,13 @@ if ((rc = child_close(pid, timeout)) != 0)
         if (quote)
           addr->message = string_cat(addr->message, &size, &ptr, US"\"", 1);
         }
+
+      /* Add previous filter timeout message, if present. */
+
+      if (*tmsg != 0)
+        addr->message = string_cat(addr->message, &size, &ptr, tmsg,
+          Ustrlen(tmsg));
+
       addr->message[ptr] = 0;  /* Ensure concatenated string terminated */
       }
     }