labelled-process fork function
authorJeremy Harris <jgh146exb@wizmail.org>
Sun, 15 Mar 2020 17:34:02 +0000 (17:34 +0000)
committerJeremy Harris <jgh146exb@wizmail.org>
Sun, 15 Mar 2020 17:34:02 +0000 (17:34 +0000)
20 files changed:
src/src/child.c
src/src/daemon.c
src/src/deliver.c
src/src/exim.c
src/src/functions.h
src/src/globals.c
src/src/globals.h
src/src/local_scan.h
src/src/log.c
src/src/moan.c
src/src/queue.c
src/src/rda.c
src/src/route.c
src/src/sieve.c
src/src/smtp_in.c
src/src/tls.c
src/src/transport.c
src/src/transports/autoreply.c
src/src/transports/pipe.c
src/src/transports/smtp.c

index c5054b6fbbe37b25b6573fd2fd8aefe072c42d1d..f6d44e1b10313b09935cb784896a23874dd6c1b0 100644 (file)
@@ -185,13 +185,15 @@ to exist, even if all calls from within Exim are changed, because it is
 documented for use from local_scan().
 
 Argument: fdptr   pointer to int for the stdin fd
 documented for use from local_scan().
 
 Argument: fdptr   pointer to int for the stdin fd
+         purpose of the child process, for debug
 Returns:          pid of the created process or -1 if anything has gone wrong
 */
 
 pid_t
 Returns:          pid of the created process or -1 if anything has gone wrong
 */
 
 pid_t
-child_open_exim(int *fdptr)
+child_open_exim_function(int * fdptr, const uschar * purpose)
 {
 {
-return child_open_exim2(fdptr, US"<>", bounce_sender_authentication);
+return child_open_exim2_function(fdptr, US"<>", bounce_sender_authentication,
+  purpose);
 }
 
 
 }
 
 
@@ -202,12 +204,14 @@ Arguments:
   fdptr                   pointer to int for the stdin fd
   sender                  for a sender address (data for -f)
   sender_authentication   authenticated sender address or NULL
   fdptr                   pointer to int for the stdin fd
   sender                  for a sender address (data for -f)
   sender_authentication   authenticated sender address or NULL
+  purpose                of the child process, for debug
 
 Returns:          pid of the created process or -1 if anything has gone wrong
 */
 
 pid_t
 
 Returns:          pid of the created process or -1 if anything has gone wrong
 */
 
 pid_t
-child_open_exim2(int *fdptr, uschar *sender, uschar *sender_authentication)
+child_open_exim2_function(int * fdptr, uschar * sender,
+  uschar * sender_authentication, const uschar * purpose)
 {
 int pfd[2];
 int save_errno;
 {
 int pfd[2];
 int save_errno;
@@ -220,7 +224,7 @@ on the wait. */
 
 if (pipe(pfd) != 0) return (pid_t)(-1);
 oldsignal = signal(SIGCHLD, SIG_DFL);
 
 if (pipe(pfd) != 0) return (pid_t)(-1);
 oldsignal = signal(SIGCHLD, SIG_DFL);
-pid = fork();
+pid = exim_fork(purpose);
 
 /* Child process: make the reading end of the pipe into the standard input and
 close the writing end. If debugging, pass debug_fd as stderr. Then re-exec
 
 /* Child process: make the reading end of the pipe into the standard input and
 close the writing end. If debugging, pass debug_fd as stderr. Then re-exec
@@ -337,7 +341,7 @@ that the child process can be waited for. We sometimes get here with it set
 otherwise. Save the old state for resetting on the wait. */
 
 oldsignal = signal(SIGCHLD, SIG_DFL);
 otherwise. Save the old state for resetting on the wait. */
 
 oldsignal = signal(SIGCHLD, SIG_DFL);
-pid = fork();
+pid = exim_fork(US"queryprogram");     /* queryprogram tpt is sole caller */
 
 /* Handle the child process. First, set the required environment. We must do
 this before messing with the pipes, in order to be able to write debugging
 
 /* Handle the child process. First, set the required environment. We must do
 this before messing with the pipes, in order to be able to write debugging
index aa36a5dc9361a713cfd5b8256491cda5b4bd7f18..a1ef1f930c985442c7a3e20d1ae388fe5efe226e 100644 (file)
@@ -367,7 +367,7 @@ if (LOGGING(smtp_connection))
 expansion above did a lookup. */
 
 search_tidyup();
 expansion above did a lookup. */
 
 search_tidyup();
-pid = fork();
+pid = exim_fork(US"daemon accept");
 
 /* Handle the child process */
 
 
 /* Handle the child process */
 
@@ -663,7 +663,7 @@ if (pid == 0)
 
       mac_smtp_fflush();
 
 
       mac_smtp_fflush();
 
-      if ((dpid = fork()) == 0)
+      if ((dpid = exim_fork(US"daemon-accept delivery")) == 0)
         {
         (void)fclose(smtp_in);
         (void)fclose(smtp_out);
         {
         (void)fclose(smtp_in);
         (void)fclose(smtp_out);
@@ -981,7 +981,7 @@ if (daemon_notifier_fd >= 0)
 
 if (f.running_in_test_harness || write_pid)
   {
 
 if (f.running_in_test_harness || write_pid)
   {
-  if ((pid = fork()) == 0)
+  if ((pid = exim_fork(US"daemon del pidfile")) == 0)
     {
     if (override_pid_file_path)
       (void)child_exec_exim(CEE_EXEC_PANIC, FALSE, NULL, FALSE, 3,
     {
     if (override_pid_file_path)
       (void)child_exec_exim(CEE_EXEC_PANIC, FALSE, NULL, FALSE, 3,
@@ -1601,7 +1601,7 @@ if (f.background_daemon)
 
   if (getppid() != 1)
     {
 
   if (getppid() != 1)
     {
-    pid_t pid = fork();
+    pid_t pid = exim_fork(US"daemon");
     if (pid < 0) log_write(0, LOG_MAIN|LOG_PANIC_DIE,
       "fork() failed when starting daemon: %s", strerror(errno));
     if (pid > 0) exit(EXIT_SUCCESS);      /* in parent process, just exit */
     if (pid < 0) log_write(0, LOG_MAIN|LOG_PANIC_DIE,
       "fork() failed when starting daemon: %s", strerror(errno));
     if (pid > 0) exit(EXIT_SUCCESS);      /* in parent process, just exit */
@@ -2130,7 +2130,7 @@ for (;;)
       if (queue_interval > 0 &&
          (local_queue_run_max <= 0 || queue_run_count < local_queue_run_max))
         {
       if (queue_interval > 0 &&
          (local_queue_run_max <= 0 || queue_run_count < local_queue_run_max))
         {
-        if ((pid = fork()) == 0)
+        if ((pid = exim_fork(US"queue runner")) == 0)
           {
           DEBUG(D_any) debug_printf("Starting queue-runner: pid %d\n",
             (int)getpid());
           {
           DEBUG(D_any) debug_printf("Starting queue-runner: pid %d\n",
             (int)getpid());
index 5c5167b3a94f42b5e9139afd2a30be14284a1ec8..5d825cd662d0ed896804463e3705e3e4d9d32495 100644 (file)
@@ -2268,7 +2268,7 @@ a clean slate and doesn't interfere with the parent process. */
 
 search_tidyup();
 
 
 search_tidyup();
 
-if ((pid = fork()) == 0)
+if ((pid = exim_fork(US"delivery (local)")) == 0)
   {
   BOOL replicate = TRUE;
 
   {
   BOOL replicate = TRUE;
 
@@ -2615,7 +2615,7 @@ if (addr->special_action == SPECIAL_WARN && addr->transport->warn_message)
       "message for %s transport): %s", addr->transport->warn_message,
       addr->transport->name, expand_string_message);
 
       "message for %s transport): %s", addr->transport->warn_message,
       addr->transport->name, expand_string_message);
 
-  else if ((pid = child_open_exim(&fd)) > 0)
+  else if ((pid = child_open_exim(&fd, US"warning message")) > 0)
     {
     FILE *f = fdopen(fd, "wb");
     if (errors_reply_to && !contains_header(US"Reply-To", warn_message))
     {
     FILE *f = fdopen(fd, "wb");
     if (errors_reply_to && !contains_header(US"Reply-To", warn_message))
@@ -4647,7 +4647,7 @@ all pipes, so I do not see a reason to use non-blocking IO here
   search_tidyup();
 
   DEBUG(D_deliver) debug_printf("forking transport process\n");
   search_tidyup();
 
   DEBUG(D_deliver) debug_printf("forking transport process\n");
-  if ((pid = fork()) == 0)
+  if ((pid = exim_fork(US"transport")) == 0)
     {
     int fd = pfd[pipe_write];
     host_item *h;
     {
     int fd = pfd[pipe_write];
     host_item *h;
@@ -7336,7 +7336,7 @@ if (addr_senddsn)
   int fd;
 
   /* create exim process to send message */
   int fd;
 
   /* create exim process to send message */
-  pid = child_open_exim(&fd);
+  pid = child_open_exim(&fd, US"DSN");
 
   DEBUG(D_deliver) debug_printf("DSN: child_open_exim returns: %d\n", pid);
 
 
   DEBUG(D_deliver) debug_printf("DSN: child_open_exim returns: %d\n", pid);
 
@@ -7537,7 +7537,7 @@ while (addr_failed)
 
     /* Make a subprocess to send a message */
 
 
     /* Make a subprocess to send a message */
 
-    if ((pid = child_open_exim(&fd)) < 0)
+    if ((pid = child_open_exim(&fd, US"bounce message")) < 0)
       log_write(0, LOG_MAIN|LOG_PANIC_DIE, "Process %d (parent %d) failed to "
         "create child process to send failure message: %s", getpid(),
         getppid(), strerror(errno));
       log_write(0, LOG_MAIN|LOG_PANIC_DIE, "Process %d (parent %d) failed to "
         "create child process to send failure message: %s", getpid(),
         getppid(), strerror(errno));
@@ -8195,7 +8195,7 @@ else if (addr_defer != (address_item *)(+1))
       {
       header_line *h;
       int fd;
       {
       header_line *h;
       int fd;
-      pid_t pid = child_open_exim(&fd);
+      pid_t pid = child_open_exim(&fd, US"delay-warning message");
 
       if (pid > 0)
         {
 
       if (pid > 0)
         {
@@ -8583,7 +8583,7 @@ if (cutthrough.cctx.sock >= 0 && cutthrough.callout_hold_only)
       goto fail;
 
     where = US"fork";
       goto fail;
 
     where = US"fork";
-    if ((pid = fork()) < 0)
+    if ((pid = exim_fork(US"tls-proxy interproc")) < 0)
       goto fail;
 
     else if (pid == 0)         /* child: fork again to totally disconnect */
       goto fail;
 
     else if (pid == 0)         /* child: fork again to totally disconnect */
index 4e4b6bb754570a71a635cd0d82d5ae2b917baf52..6bde8fd966290272ccc08473a606eae599d3c222 100644 (file)
@@ -4608,7 +4608,7 @@ if (msg_action_arg > 0 && msg_action != MSG_LOAD)
     pid_t pid;
     if (i == argc - 1)
       (void)deliver_message(argv[i], forced_delivery, deliver_give_up);
     pid_t pid;
     if (i == argc - 1)
       (void)deliver_message(argv[i], forced_delivery, deliver_give_up);
-    else if ((pid = fork()) == 0)
+    else if ((pid = exim_fork(US"cmdline-delivery")) == 0)
       {
       (void)deliver_message(argv[i], forced_delivery, deliver_give_up);
       exim_underbar_exit(EXIT_SUCCESS, US"cmdline-delivery");
       {
       (void)deliver_message(argv[i], forced_delivery, deliver_give_up);
       exim_underbar_exit(EXIT_SUCCESS, US"cmdline-delivery");
@@ -5694,7 +5694,7 @@ while (more)
     pid_t pid;
     search_tidyup();
 
     pid_t pid;
     search_tidyup();
 
-    if ((pid = fork()) == 0)
+    if ((pid = exim_fork(US"local-accept delivery")) == 0)
       {
       int rc;
       close_unwanted();      /* Close unwanted file descriptors and TLS */
       {
       int rc;
       close_unwanted();      /* Close unwanted file descriptors and TLS */
index 042006f95fe2f02aaa21df2bff19ffb7279a034d..9e71d0c20efde1dcaa7c93af982ad268058db265 100644 (file)
@@ -150,6 +150,9 @@ extern void    bits_set(unsigned int *, size_t, int *);
 extern void    cancel_cutthrough_connection(BOOL, const uschar *);
 extern int     check_host(void *, const uschar *, const uschar **, uschar **);
 extern uschar **child_exec_exim(int, BOOL, int *, BOOL, int, ...);
 extern void    cancel_cutthrough_connection(BOOL, const uschar *);
 extern int     check_host(void *, const uschar *, const uschar **, uschar **);
 extern uschar **child_exec_exim(int, BOOL, int *, BOOL, int, ...);
+extern pid_t   child_open_exim_function(int *, const uschar *);
+extern pid_t   child_open_exim2_function(int *, uschar *, uschar *,
+                const uschar *);
 extern pid_t   child_open_uid(const uschar **, const uschar **, int,
                 uid_t *, gid_t *, int *, int *, uschar *, BOOL);
 extern BOOL    cleanup_environment(void);
 extern pid_t   child_open_uid(const uschar **, const uschar **, int,
                 uid_t *, gid_t *, int *, int *, uschar *, BOOL);
 extern BOOL    cleanup_environment(void);
@@ -1108,6 +1111,21 @@ errno = EACCES;
 return NULL;
 }
 
 return NULL;
 }
 
+/******************************************************************************/
+/* Process manipulation */
+
+static inline pid_t
+exim_fork(const unsigned char * purpose)
+{
+pid_t pid = fork();
+if (pid == 0) process_purpose = purpose;
+return pid;
+}
+
+#define child_open_exim(p, r)        child_open_exim_function((p), (r))
+#define child_open_exim2(p, s, a, r) child_open_exim2_function((p), (s), (a), (r))
+
+/******************************************************************************/
 #endif /* !MACRO_PREDEF */
 
 #endif  /* _FUNCTIONS_H_ */
 #endif /* !MACRO_PREDEF */
 
 #endif  /* _FUNCTIONS_H_ */
index a771f1193d7bc87982d03b4434fe783157dfc0e6..28e78d4d6657b570f8bea8674c94b803ebc0855b 100644 (file)
@@ -1188,6 +1188,7 @@ uschar *primary_hostname       = NULL;
 uschar *process_info;
 int     process_info_len       = 0;
 uschar *process_log_path       = NULL;
 uschar *process_info;
 int     process_info_len       = 0;
 uschar *process_log_path       = NULL;
+const uschar *process_purpose  = US"fresh exec";
 
 #if defined(SUPPORT_PROXY) || defined(SUPPORT_SOCKS)
 uschar *hosts_proxy            = NULL;
 
 #if defined(SUPPORT_PROXY) || defined(SUPPORT_SOCKS)
 uschar *hosts_proxy            = NULL;
index 28d170cdc700c152464271c43cf74c775d2b1b8e..c9222743eaf19793d064ad53ee6b6c40d021c5c6 100644 (file)
@@ -771,6 +771,7 @@ extern BOOL    print_topbitchars;      /* Topbit chars are printing chars */
 extern uschar *process_info;           /* For SIGUSR1 output */
 extern int     process_info_len;
 extern uschar *process_log_path;       /* Alternate path */
 extern uschar *process_info;           /* For SIGUSR1 output */
 extern int     process_info_len;
 extern uschar *process_log_path;       /* Alternate path */
+extern const uschar *process_purpose;  /* for debug output */
 extern BOOL    prod_requires_admin;    /* TRUE if prodding requires admin */
 
 #if defined(SUPPORT_PROXY) || defined(SUPPORT_SOCKS)
 extern BOOL    prod_requires_admin;    /* TRUE if prodding requires admin */
 
 #if defined(SUPPORT_PROXY) || defined(SUPPORT_SOCKS)
index 206a843eccc25480b109d07aa15856599ae2ad5b..bb131d380cf1e5df7da4fc6aec010fa745fee8cd 100644 (file)
@@ -31,6 +31,21 @@ settings, and the store functions. */
 #include "store.h"
 
 
 #include "store.h"
 
 
+/* Some people (Marc Merlin et al) are maintaining a patch that allows for
+dynamic local_scan() libraries. This code is not yet in Exim proper, but it
+helps the maintainers if we keep their ABI version numbers here. This may
+mutate into more general support later. The major number is increased when the
+ABI is changed in a non backward compatible way. The minor number is increased
+each time a new feature is added (in a way that doesn't break backward
+compatibility). */
+
+#define LOCAL_SCAN_ABI_VERSION_MAJOR 4
+#define LOCAL_SCAN_ABI_VERSION_MINOR 1
+#define LOCAL_SCAN_ABI_VERSION \
+  LOCAL_SCAN_ABI_VERSION_MAJOR.LOCAL_SCAN_ABI_VERSION_MINOR
+
+
+
 /* The function and its return codes. */
 
 extern int local_scan(int, uschar **);
 /* The function and its return codes. */
 
 extern int local_scan(int, uschar **);
@@ -99,19 +114,6 @@ the name of the data file to be present in the first line. */
 
 #define SPOOL_DATA_START_OFFSET (MESSAGE_ID_LENGTH+3)
 
 
 #define SPOOL_DATA_START_OFFSET (MESSAGE_ID_LENGTH+3)
 
-/* Some people (Marc Merlin et al) are maintaining a patch that allows for
-dynamic local_scan() libraries. This code is not yet in Exim proper, but it
-helps the maintainers if we keep their ABI version numbers here. This may
-mutate into more general support later. The major number is increased when the
-ABI is changed in a non backward compatible way. The minor number is increased
-each time a new feature is added (in a way that doesn't break backward
-compatibility). */
-
-#define LOCAL_SCAN_ABI_VERSION_MAJOR 4
-#define LOCAL_SCAN_ABI_VERSION_MINOR 0
-#define LOCAL_SCAN_ABI_VERSION \
-  LOCAL_SCAN_ABI_VERSION_MAJOR.LOCAL_SCAN_ABI_VERSION_MINOR
-
 /* Structure definitions that are documented as visible in the function. */
 
 typedef struct header_line {
 /* Structure definitions that are documented as visible in the function. */
 
 typedef struct header_line {
@@ -180,8 +182,6 @@ extern BOOL    smtp_input;             /* TRUE if input is via SMTP */
 
 extern int     child_close(pid_t, int);
 extern pid_t   child_open(uschar **, uschar **, int, int *, int *, BOOL);
 
 extern int     child_close(pid_t, int);
 extern pid_t   child_open(uschar **, uschar **, int, int *, int *, BOOL);
-extern pid_t   child_open_exim(int *);
-extern pid_t   child_open_exim2(int *, uschar *, uschar *);
 extern void    debug_printf(const char *, ...) PRINTF_FUNCTION(1,2);
 extern uschar *expand_string(uschar *);
 extern void    header_add(int, const char *, ...);
 extern void    debug_printf(const char *, ...) PRINTF_FUNCTION(1,2);
 extern uschar *expand_string(uschar *);
 extern void    header_add(int, const char *, ...);
@@ -223,10 +223,14 @@ with the original name. */
 # define string_copy(s) string_copy_function(s)
 # define string_copyn(s, n) string_copyn_function((s), (n))
 # define string_copy_taint(s, t) string_copy_taint_function((s), (t))
 # define string_copy(s) string_copy_function(s)
 # define string_copyn(s, n) string_copyn_function((s), (n))
 # define string_copy_taint(s, t) string_copy_taint_function((s), (t))
+# define child_open_exim(p)        child_open_exim_function((p), US"from local_scan")
+# define child_open_exim2(p, s, a) child_open_exim2_function((p), (s), (a), US"from local_scan")
 
 extern uschar * string_copy_function(const uschar *);
 extern uschar * string_copyn_function(const uschar *, int n);
 extern uschar * string_copy_taint_function(const uschar *, BOOL tainted);
 
 extern uschar * string_copy_function(const uschar *);
 extern uschar * string_copyn_function(const uschar *, int n);
 extern uschar * string_copy_taint_function(const uschar *, BOOL tainted);
+extern pid_t    child_open_exim_function(int *, const uschar *);
+extern pid_t    child_open_exim2_function(int *, uschar *, uschar *, const uschar *);
 #endif
 
 /* End of local_scan.h */
 #endif
 
 /* End of local_scan.h */
index e2543a74dda99130022ccc8cc2025c59f7ab30fc..e80c17757d5284c30262b1c10333672dca2a4492 100644 (file)
@@ -313,7 +313,7 @@ Returns:       a file descriptor, or < 0 on failure (errno set)
 int
 log_create_as_exim(uschar *name)
 {
 int
 log_create_as_exim(uschar *name)
 {
-pid_t pid = fork();
+pid_t pid = exim_fork(US"logfile create");
 int status = 1;
 int fd = -1;
 
 int status = 1;
 int fd = -1;
 
index 31d033c1adcf66ed51c9ad65307212fea66804a5..51f5da58a28ee723f1c141815251c9e6a4469705 100644 (file)
@@ -160,15 +160,16 @@ if (  ident == ERRMESS_DMARC_FORENSIC
    && (s2 = expand_string(string_sprintf("${address:%s}", s)))
    && *s2
    )
    && (s2 = expand_string(string_sprintf("${address:%s}", s)))
    && *s2
    )
-  pid = child_open_exim2(&fd, s2, bounce_sender_authentication);
+  pid = child_open_exim2(&fd, s2, bounce_sender_authentication,
+               US"moan_send_message");
 else
   {
   s = NULL;
 else
   {
   s = NULL;
-  pid = child_open_exim(&fd);
+  pid = child_open_exim(&fd, US"moan_send_message");
   }
 
 #else
   }
 
 #else
-pid = child_open_exim(&fd);
+pid = child_open_exim(&fd, US"moan_send_message");
 #endif
 
 if (pid < 0)
 #endif
 
 if (pid < 0)
@@ -584,7 +585,7 @@ moan_tell_someone(uschar *who, address_item *addr,
 FILE *f;
 va_list ap;
 int fd;
 FILE *f;
 va_list ap;
 int fd;
-int pid = child_open_exim(&fd);
+int pid = child_open_exim(&fd, US"moan_tell_someone");
 
 if (pid < 0)
   {
 
 if (pid < 0)
   {
@@ -820,7 +821,7 @@ if (!(s = expand_string(syntax_errors_to)))
 /* If we can't create a process to send the message, just forget about
 it. */
 
 /* If we can't create a process to send the message, just forget about
 it. */
 
-pid = child_open_exim(&fd);
+pid = child_open_exim(&fd, US"moan_skipped_syntax_errors");
 
 if (pid < 0)
   {
 
 if (pid < 0)
   {
index c9ac84be6e778138c711d55cd62181954cead3b8..2b64f52296c7f5f72710f406d0d2cd7c787196f6 100644 (file)
@@ -497,7 +497,7 @@ for (int i = queue_run_in_order ? -1 : 0;
       else
        for (i = 0; qpid[i]; ) i++;
       DEBUG(D_queue_run) debug_printf("q2stage forking\n");
       else
        for (i = 0; qpid[i]; ) i++;
       DEBUG(D_queue_run) debug_printf("q2stage forking\n");
-      if ((qpid[i] = fork()))
+      if ((qpid[i] = exim_fork(US"qrun phase one")))
        continue;       /* parent loops around */
       DEBUG(D_queue_run) debug_printf("q2stage child\n");
       }
        continue;       /* parent loops around */
       DEBUG(D_queue_run) debug_printf("q2stage child\n");
       }
@@ -651,7 +651,7 @@ for (int i = queue_run_in_order ? -1 : 0;
 #endif
 
 single_item_retry:
 #endif
 
 single_item_retry:
-    if ((pid = fork()) == 0)
+    if ((pid = exim_fork(US"qrun delivery")) == 0)
       {
       int rc;
       testharness_pause_ms(100);
       {
       int rc;
       testharness_pause_ms(100);
index 547a8bf3b9444b6796fcb24e0df38d801aea9c5b..85791c2f73dc7d5cc59b01965e126ae90fec0364 100644 (file)
@@ -615,7 +615,7 @@ with the parent process. */
 oldsignal = signal(SIGCHLD, SIG_DFL);
 search_tidyup();
 
 oldsignal = signal(SIGCHLD, SIG_DFL);
 search_tidyup();
 
-if ((pid = fork()) == 0)
+if ((pid = exim_fork(US"router interpret")) == 0)
   {
   header_line *waslast = header_last;   /* Save last header */
 
   {
   header_line *waslast = header_last;   /* Save last header */
 
index fd3cb3e6483675909697b78c5ead65013e0ce95d..6226b0685c16b509391b577a7f32a029b428c076 100644 (file)
@@ -736,7 +736,7 @@ while ((check = string_nextinlist(&listptr, &sep, buffer, sizeof(buffer))))
     otherwise. Save the old state for resetting on the wait. */
 
     oldsignal = signal(SIGCHLD, SIG_DFL);
     otherwise. Save the old state for resetting on the wait. */
 
     oldsignal = signal(SIGCHLD, SIG_DFL);
-    pid = fork();
+    pid = exim_fork(US"require-files");
 
     /* If fork() fails, reinstate the original error and behave as if
     this block of code were not present. This is the same behaviour as happens
 
     /* If fork() fails, reinstate the original error and behave as if
     this block of code were not present. This is the same behaviour as happens
index 5e8d1e6f47760c6a92c748e574208ad7eb48df65..e07b7da1860cf310e0b7ed13200dc965d8c4294f 100644 (file)
@@ -3084,7 +3084,8 @@ while (*filter->pc)
             {
             int pid, fd;
 
             {
             int pid, fd;
 
-            if ((pid = child_open_exim2(&fd,envelope_from,envelope_from))>=1)
+            if ((pid = child_open_exim2(&fd, envelope_from, envelope_from,
+                       US"sieve-notify")) >= 1)
               {
               FILE *f;
               uschar *buffer;
               {
               FILE *f;
               uschar *buffer;
@@ -3092,7 +3093,8 @@ while (*filter->pc)
 
               f = fdopen(fd, "wb");
               fprintf(f,"From: %s\n", from.length == -1
 
               f = fdopen(fd, "wb");
               fprintf(f,"From: %s\n", from.length == -1
-               ? expand_string(US"$local_part_prefix$local_part$local_part_suffix@$domain") : from.character);
+               ? expand_string(US"$local_part_prefix$local_part$local_part_suffix@$domain")
+               : from.character);
               for (string_item * p = recipient; p; p=p->next)
                fprintf(f,"To: %s\n",p->text);
               fprintf(f,"Auto-Submitted: auto-notified; %s\n",filter->enotify_mailto_owner);
               for (string_item * p = recipient; p; p=p->next)
                fprintf(f,"To: %s\n",p->text);
               fprintf(f,"Auto-Submitted: auto-notified; %s\n",filter->enotify_mailto_owner);
@@ -3103,9 +3105,11 @@ while (*filter->pc)
                 message.length=Ustrlen(message.character);
                 }
               /* Allocation is larger than necessary, but enough even for split MIME words */
                 message.length=Ustrlen(message.character);
                 }
               /* Allocation is larger than necessary, but enough even for split MIME words */
-              buffer_capacity=32+4*message.length;
+              buffer_capacity = 32 + 4*message.length;
               buffer=store_get(buffer_capacity, TRUE);
               buffer=store_get(buffer_capacity, TRUE);
-              if (message.length!=-1) fprintf(f,"Subject: %s\n",parse_quote_2047(message.character, message.length, US"utf-8", buffer, buffer_capacity, TRUE));
+              if (message.length != -1)
+               fprintf(f, "Subject: %s\n", parse_quote_2047(message.character,
+                 message.length, US"utf-8", buffer, buffer_capacity, TRUE));
               fprintf(f,"\n");
               if (body.length>0) fprintf(f,"%s\n",body.character);
               fflush(f);
               fprintf(f,"\n");
               if (body.length>0) fprintf(f,"%s\n",body.character);
               fflush(f);
@@ -3113,27 +3117,17 @@ while (*filter->pc)
               (void)child_close(pid, 0);
               }
             }
               (void)child_close(pid, 0);
               }
             }
-          if ((filter_test != FTEST_NONE && debug_selector != 0) || (debug_selector & D_filter) != 0)
-            {
+          if ((filter_test != FTEST_NONE && debug_selector != 0) || debug_selector & D_filter)
             debug_printf("Notification to `%s': '%s'.\n",method.character,message.length!=-1 ? message.character : CUS "");
             debug_printf("Notification to `%s': '%s'.\n",method.character,message.length!=-1 ? message.character : CUS "");
-            }
 #endif
           }
         else
 #endif
           }
         else
-          {
-          if ((filter_test != FTEST_NONE && debug_selector != 0) || (debug_selector & D_filter) != 0)
-            {
+          if ((filter_test != FTEST_NONE && debug_selector != 0) || debug_selector & D_filter)
             debug_printf("Repeated notification to `%s' ignored.\n",method.character);
             debug_printf("Repeated notification to `%s' ignored.\n",method.character);
-            }
-          }
         }
       else
         }
       else
-        {
-        if ((filter_test != FTEST_NONE && debug_selector != 0) || (debug_selector & D_filter) != 0)
-          {
+        if ((filter_test != FTEST_NONE && debug_selector != 0) || debug_selector & D_filter)
           debug_printf("Ignoring notification, triggering message contains Auto-submitted: field.\n");
           debug_printf("Ignoring notification, triggering message contains Auto-submitted: field.\n");
-          }
-        }
       }
     }
 #endif
       }
     }
 #endif
index 66f752dd4a3acdaa394c92827f71f12046cd53c0..b5f44f5482d4cc3922d1fab25c88eeb859b014ae 100644 (file)
@@ -5759,7 +5759,7 @@ while (done <= 0)
 
       oldsignal = signal(SIGCHLD, SIG_IGN);
 
 
       oldsignal = signal(SIGCHLD, SIG_IGN);
 
-      if ((pid = fork()) == 0)
+      if ((pid = exim_fork(US"etrn command")) == 0)
        {
        smtp_input = FALSE;       /* This process is not associated with the */
        (void)fclose(smtp_in);    /* SMTP call any more. */
        {
        smtp_input = FALSE;       /* This process is not associated with the */
        (void)fclose(smtp_in);    /* SMTP call any more. */
@@ -5770,7 +5770,8 @@ while (done <= 0)
        /* If not serializing, do the exec right away. Otherwise, fork down
        into another process. */
 
        /* If not serializing, do the exec right away. Otherwise, fork down
        into another process. */
 
-       if (!smtp_etrn_serialize || (pid = fork()) == 0)
+       if (  !smtp_etrn_serialize 
+          || (pid = exim_fork(US"etrn serialised command")) == 0)
          {
          DEBUG(D_exec) debug_print_argv(argv);
          exim_nullstd();                   /* Ensure std{in,out,err} exist */
          {
          DEBUG(D_exec) debug_print_argv(argv);
          exim_nullstd();                   /* Ensure std{in,out,err} exist */
index a0cfcbf2524ab5cbd3feee09922e5c77d8ad5abd..2f9faa3c74710c294991f9f89ae28bf593529001 100644 (file)
@@ -441,7 +441,7 @@ else if (!nowarn && !tls_certificate)
 oldsignal = signal(SIGCHLD, SIG_DFL);
 
 fflush(NULL);
 oldsignal = signal(SIGCHLD, SIG_DFL);
 
 fflush(NULL);
-if ((pid = fork()) < 0)
+if ((pid = exim_fork(US"cipher validate")) < 0)
   log_write(0, LOG_MAIN|LOG_PANIC_DIE, "fork failed for TLS check");
 
 if (pid == 0)
   log_write(0, LOG_MAIN|LOG_PANIC_DIE, "fork failed for TLS check");
 
 if (pid == 0)
index 3eb1c8097e04b3657b9e9f072b84d00d1dea7a70..d92ad4c370656f1463785d9bec739d6fce432f50 100644 (file)
@@ -1248,7 +1248,7 @@ via a(nother) pipe. While writing to the filter, we do not do the CRLF,
 smtp dots, or check string processing. */
 
 if (pipe(pfd) != 0) goto TIDY_UP;      /* errno set */
 smtp dots, or check string processing. */
 
 if (pipe(pfd) != 0) goto TIDY_UP;      /* errno set */
-if ((write_pid = fork()) == 0)
+if ((write_pid = exim_fork(US"transport filter")) == 0)
   {
   BOOL rc;
   (void)close(fd_read);
   {
   BOOL rc;
   (void)close(fd_read);
@@ -1954,14 +1954,14 @@ int status;
 
 DEBUG(D_transport) debug_printf("transport_pass_socket entered\n");
 
 
 DEBUG(D_transport) debug_printf("transport_pass_socket entered\n");
 
-if ((pid = fork()) == 0)
+if ((pid = exim_fork(US"continued-transport interproc")) == 0)
   {
   /* Disconnect entirely from the parent process. If we are running in the
   test harness, wait for a bit to allow the previous process time to finish,
   write the log, etc., so that the output is always in the same order for
   automatic comparison. */
 
   {
   /* Disconnect entirely from the parent process. If we are running in the
   test harness, wait for a bit to allow the previous process time to finish,
   write the log, etc., so that the output is always in the same order for
   automatic comparison. */
 
-  if ((pid = fork()) != 0)
+  if ((pid = exim_fork(US"continued-transport")) != 0)
     {
     DEBUG(D_transport) debug_printf("transport_pass_socket succeeded (final-pid %d)\n", pid);
     _exit(EXIT_SUCCESS);
     {
     DEBUG(D_transport) debug_printf("transport_pass_socket succeeded (final-pid %d)\n", pid);
     _exit(EXIT_SUCCESS);
index 4b5ef8e1748844934fb948b1e31bdb2399523911..2b487b435a62b66f1f61701bf775f42e44a9520f 100644 (file)
@@ -567,12 +567,10 @@ if (file)
 
 /* Make a subprocess to send the message */
 
 
 /* Make a subprocess to send the message */
 
-pid = child_open_exim(&fd);
-
-/* Creation of child failed; defer this delivery. */
-
-if (pid < 0)
+if ((pid = child_open_exim(&fd, US"autoreply")) < 0)
   {
   {
+  /* Creation of child failed; defer this delivery. */
+
   addr->transport_return = DEFER;
   addr->basic_errno = errno;
   addr->message = string_sprintf("Failed to create child process to send "
   addr->transport_return = DEFER;
   addr->basic_errno = errno;
   addr->message = string_sprintf("Failed to create child process to send "
index ca22f2659f22d65aaef6aef899dec28a8c1e9bf8..83272d80ae12cadc04e1fa6479d53d1219a83a6f 100644 (file)
@@ -737,7 +737,7 @@ tctx.u.fd = fd_in;
 
 /* Now fork a process to handle the output that comes down the pipe. */
 
 
 /* Now fork a process to handle the output that comes down the pipe. */
 
-if ((outpid = fork()) < 0)
+if ((outpid = exim_fork(US"pipe-transport output")) < 0)
   {
   addr->basic_errno = errno;
   addr->transport_return = DEFER;
   {
   addr->basic_errno = errno;
   addr->transport_return = DEFER;
index 6f999097a6d68c7699693103c50b66047fb21f8a..459110b80df1554100c571da4a443efa5e09583c 100644 (file)
@@ -3284,7 +3284,7 @@ int max_fd = MAX(pfd[0], tls_out.active.sock) + 1;
 int rc, i;
 
 close(pfd[1]);
 int rc, i;
 
 close(pfd[1]);
-if ((rc = fork()))
+if ((rc = exim_fork(US"tls proxy")))
   {
   DEBUG(D_transport) debug_printf("proxy-proc final-pid %d\n", rc);
   _exit(rc < 0 ? EXIT_FAILURE : EXIT_SUCCESS);
   {
   DEBUG(D_transport) debug_printf("proxy-proc final-pid %d\n", rc);
   _exit(rc < 0 ? EXIT_FAILURE : EXIT_SUCCESS);
@@ -4279,7 +4279,7 @@ propagate it from the initial
 #ifndef DISABLE_TLS
        if (tls_out.active.sock >= 0)
          {
 #ifndef DISABLE_TLS
        if (tls_out.active.sock >= 0)
          {
-         int pid = fork();
+         int pid = exim_fork(US"tls proxy interproc");
          if (pid == 0)         /* child; fork again to disconnect totally */
            {
            testharness_pause_ms(100); /* let parent debug out */
          if (pid == 0)         /* child; fork again to disconnect totally */
            {
            testharness_pause_ms(100); /* let parent debug out */