tidying
[exim.git] / src / src / exim.c
index 63ac620e7b1351b36e4d73294a809d4486e9fbdf..f7f8b251aeed8b25b20c699b2fa033df72a8e142 100644 (file)
@@ -342,11 +342,9 @@ Returns:     nothing
 void
 millisleep(int msec)
 {
-struct itimerval itval;
-itval.it_interval.tv_sec = 0;
-itval.it_interval.tv_usec = 0;
-itval.it_value.tv_sec = msec/1000;
-itval.it_value.tv_usec = (msec % 1000) * 1000;
+struct itimerval itval = {.it_interval = {.tv_sec = 0, .tv_usec = 0},
+                         .it_value = {.tv_sec = msec/1000,
+                                      .tv_usec = (msec % 1000) * 1000}};
 milliwait(&itval);
 }
 
@@ -727,9 +725,13 @@ exit(rc);
 
 
 void
-exim_underbar_exit(int rc)
+exim_underbar_exit(int rc, const uschar * process)
 {
 store_exit();
+DEBUG(D_any)
+  debug_printf(">>>>>>>>>>>>>>>> Exim pid=%d %s%s%sterminating with rc=%d "
+    ">>>>>>>>>>>>>>>>\n", (int)getpid(),
+    process ? "(" : "", process, process ? ") " : "", rc);
 _exit(rc);
 }
 
@@ -4604,10 +4606,10 @@ 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);
-    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);
+      exim_underbar_exit(EXIT_SUCCESS, US"cmdline-delivery");
       }
     else if (pid < 0)
       {
@@ -4627,10 +4629,10 @@ turn into a queue runner, with an optional starting message id. */
 if (queue_interval == 0 && !f.daemon_listen)
   {
   DEBUG(D_queue_run) debug_printf("Single queue run%s%s%s%s\n",
-    (start_queue_run_id == NULL)? US"" : US" starting at ",
-    (start_queue_run_id == NULL)? US"" : start_queue_run_id,
-    (stop_queue_run_id == NULL)?  US"" : US" stopping at ",
-    (stop_queue_run_id == NULL)?  US"" : stop_queue_run_id);
+    start_queue_run_id ? US" starting at " : US"",
+    start_queue_run_id ? start_queue_run_id: US"",
+    stop_queue_run_id ?  US" stopping at " : US"",
+    stop_queue_run_id ?  stop_queue_run_id : US"");
   if (*queue_name)
     set_process_info("running the '%s' queue (single queue run)", queue_name);
   else
@@ -5690,7 +5692,7 @@ while (more)
     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 */
@@ -5710,7 +5712,7 @@ while (more)
       rc = deliver_message(message_id, FALSE, FALSE);
       search_tidyup();
       exim_underbar_exit(!mua_wrapper || rc == DELIVER_MUA_SUCCEEDED
-        ? EXIT_SUCCESS : EXIT_FAILURE);
+        ? EXIT_SUCCESS : EXIT_FAILURE, US"cmdline-delivery");
       }
 
     if (pid < 0)