summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeremy Harris <jgh146exb@wizmail.org>2017-10-20 19:30:20 +0100
committerJeremy Harris <jgh146exb@wizmail.org>2017-10-20 19:30:20 +0100
commit9bfb7e1bec2b3b6022c2e7b42df9ac606693dcfd (patch)
treeec13eef8d0df504ed55b7fac35a3b60fae350d05 /src
parent2566035fb6e86813da28743a0f6d784e84451bd2 (diff)
Debug: output type of process as it terminates
Diffstat (limited to 'src')
-rw-r--r--src/src/deliver.c4
-rw-r--r--src/src/exim.c63
-rw-r--r--src/src/functions.h2
-rw-r--r--src/src/log.c6
-rw-r--r--src/src/moan.c2
-rw-r--r--src/src/receive.c8
-rw-r--r--src/src/smtp_in.c6
-rw-r--r--src/src/transports/smtp.c4
8 files changed, 45 insertions, 50 deletions
diff --git a/src/src/deliver.c b/src/src/deliver.c
index b036a846a..89ad7e5ea 100644
--- a/src/src/deliver.c
+++ b/src/src/deliver.c
@@ -8510,9 +8510,9 @@ if (cutthrough.fd >= 0 && cutthrough.callout_hold_only)
{
close(pfd[1]);
if ((pid = fork()))
- _exit(pid ? EXIT_FAILURE : EXIT_SUCCESS);
+ _exit(pid < 0 ? EXIT_FAILURE : EXIT_SUCCESS);
smtp_proxy_tls(big_buffer, big_buffer_size, pfd[0], 5*60);
- exim_exit(0);
+ exim_exit(0, US"TLS proxy");
}
close(pfd[0]);
diff --git a/src/src/exim.c b/src/src/exim.c
index e199279b8..5a1437c3b 100644
--- a/src/src/exim.c
+++ b/src/src/exim.c
@@ -658,12 +658,13 @@ Returns: does not return
*/
void
-exim_exit(int rc)
+exim_exit(int rc, const uschar * process)
{
search_tidyup();
DEBUG(D_any)
- debug_printf(">>>>>>>>>>>>>>>> Exim pid=%d terminating with rc=%d "
- ">>>>>>>>>>>>>>>>\n", (int)getpid(), rc);
+ debug_printf(">>>>>>>>>>>>>>>> Exim pid=%d %s%s%sterminating with rc=%d "
+ ">>>>>>>>>>>>>>>>\n", (int)getpid(),
+ process ? "(" : "", process, process ? ") " : "", rc);
exit(rc);
}
@@ -4483,7 +4484,7 @@ if (test_retry_arg >= 0)
if (test_retry_arg >= argc)
{
printf("-brt needs a domain or address argument\n");
- exim_exit(EXIT_FAILURE);
+ exim_exit(EXIT_FAILURE, US"main");
}
s1 = argv[test_retry_arg++];
s2 = NULL;
@@ -4589,7 +4590,7 @@ if (test_retry_arg >= 0)
printf("\n");
}
- exim_exit(EXIT_SUCCESS);
+ exim_exit(EXIT_SUCCESS, US"main");
}
/* Handle a request to list one or more configuration options */
@@ -4613,14 +4614,14 @@ if (list_options)
}
else readconf_print(argv[i], NULL, flag_n);
}
- exim_exit(EXIT_SUCCESS);
+ exim_exit(EXIT_SUCCESS, US"main");
}
if (list_config)
{
set_process_info("listing config");
readconf_print(US"config", NULL, flag_n);
- exim_exit(EXIT_SUCCESS);
+ exim_exit(EXIT_SUCCESS, US"main");
}
@@ -4649,7 +4650,7 @@ if (msg_action_arg > 0 && msg_action != MSG_LOAD)
if (prod_requires_admin && !admin_user)
{
fprintf(stderr, "exim: Permission denied\n");
- exim_exit(EXIT_FAILURE);
+ exim_exit(EXIT_FAILURE, US"main");
}
set_process_info("delivering specified messages");
if (deliver_give_up) forced_delivery = deliver_force_thaw = TRUE;
@@ -4668,11 +4669,11 @@ if (msg_action_arg > 0 && msg_action != MSG_LOAD)
{
fprintf(stderr, "failed to fork delivery process for %s: %s\n", argv[i],
strerror(errno));
- exim_exit(EXIT_FAILURE);
+ exim_exit(EXIT_FAILURE, US"main");
}
else wait(&status);
}
- exim_exit(EXIT_SUCCESS);
+ exim_exit(EXIT_SUCCESS, US"main");
}
@@ -4691,7 +4692,7 @@ if (queue_interval == 0 && !daemon_listen)
else
set_process_info("running the queue (single queue run)");
queue_run(start_queue_run_id, stop_queue_run_id, FALSE);
- exim_exit(EXIT_SUCCESS);
+ exim_exit(EXIT_SUCCESS, US"main");
}
@@ -4844,10 +4845,10 @@ if (test_rewrite_arg >= 0)
if (test_rewrite_arg >= argc)
{
printf("-brw needs an address argument\n");
- exim_exit(EXIT_FAILURE);
+ exim_exit(EXIT_FAILURE, US"main");
}
rewrite_test(argv[test_rewrite_arg]);
- exim_exit(EXIT_SUCCESS);
+ exim_exit(EXIT_SUCCESS, US"main");
}
/* A locally-supplied message is considered to be coming from a local user
@@ -4962,7 +4963,7 @@ if (verify_address_mode || address_test_mode)
}
route_tidyup();
- exim_exit(exit_value);
+ exim_exit(exit_value, US"main");
}
/* Handle expansion checking. Either expand items on the command line, or read
@@ -5064,7 +5065,7 @@ if (expansion_test)
deliver_datafile = -1;
}
- exim_exit(EXIT_SUCCESS);
+ exim_exit(EXIT_SUCCESS, US"main");
}
@@ -5158,7 +5159,7 @@ if (host_checking)
}
smtp_log_no_mail();
}
- exim_exit(EXIT_SUCCESS);
+ exim_exit(EXIT_SUCCESS, US"main");
}
@@ -5322,7 +5323,7 @@ if (smtp_input)
if (!smtp_start_session())
{
mac_smtp_fflush();
- exim_exit(EXIT_SUCCESS);
+ exim_exit(EXIT_SUCCESS, US"smtp_start toplevel");
}
}
@@ -5437,14 +5438,14 @@ while (more)
cancel_cutthrough_connection(TRUE, US"receive dropped");
if (more) goto moreloop;
smtp_log_no_mail(); /* Log no mail if configured */
- exim_exit(EXIT_FAILURE);
+ exim_exit(EXIT_FAILURE, US"receive toplevel");
}
}
else
{
cancel_cutthrough_connection(TRUE, US"message setup dropped");
smtp_log_no_mail(); /* Log no mail if configured */
- exim_exit((rc == 0)? EXIT_SUCCESS : EXIT_FAILURE);
+ exim_exit(rc ? EXIT_FAILURE : EXIT_SUCCESS, US"msg setup toplevel");
}
}
@@ -5495,14 +5496,12 @@ while (more)
if (error_handling == ERRORS_STDERR)
{
fprintf(stderr, "exim: too many recipients\n");
- exim_exit(EXIT_FAILURE);
+ exim_exit(EXIT_FAILURE, US"main");
}
else
- {
return
moan_to_sender(ERRMESS_TOOMANYRECIP, NULL, NULL, stdin, TRUE)?
errors_sender_rc : EXIT_FAILURE;
- }
#ifdef SUPPORT_I18N
{
@@ -5531,7 +5530,7 @@ while (more)
{
fprintf(stderr, "exim: bad recipient address \"%s\": %s\n",
string_printing(list[i]), errmess);
- exim_exit(EXIT_FAILURE);
+ exim_exit(EXIT_FAILURE, US"main");
}
else
{
@@ -5604,7 +5603,7 @@ while (more)
for real; when reading the headers of a message for filter testing,
it is TRUE if the headers were terminated by '.' and FALSE otherwise. */
- if (message_id[0] == 0) exim_exit(EXIT_FAILURE);
+ if (message_id[0] == 0) exim_exit(EXIT_FAILURE, US"main");
} /* Non-SMTP message reception */
/* If this is a filter testing run, there are headers in store, but
@@ -5649,7 +5648,7 @@ while (more)
if (chdir("/")) /* Get away from wherever the user is running this from */
{
DEBUG(D_receive) debug_printf("chdir(\"/\") failed\n");
- exim_exit(EXIT_FAILURE);
+ exim_exit(EXIT_FAILURE, US"main");
}
/* Now we run either a system filter test, or a user filter test, or both.
@@ -5658,20 +5657,16 @@ while (more)
explicitly. */
if ((filter_test & FTEST_SYSTEM) != 0)
- {
if (!filter_runtest(filter_sfd, filter_test_sfile, TRUE, more))
- exim_exit(EXIT_FAILURE);
- }
+ exim_exit(EXIT_FAILURE, US"main");
memcpy(filter_sn, filter_n, sizeof(filter_sn));
if ((filter_test & FTEST_USER) != 0)
- {
if (!filter_runtest(filter_ufd, filter_test_ufile, FALSE, more))
- exim_exit(EXIT_FAILURE);
- }
+ exim_exit(EXIT_FAILURE, US"main");
- exim_exit(EXIT_SUCCESS);
+ exim_exit(EXIT_SUCCESS, US"main");
}
/* Else act on the result of message reception. We should not get here unless
@@ -5797,7 +5792,7 @@ while (more)
log_write(0, LOG_MAIN|LOG_PANIC,
"process %d crashed with signal %d while delivering %s",
(int)pid, status & 0x00ff, message_id);
- if (mua_wrapper && (status & 0xffff) != 0) exim_exit(EXIT_FAILURE);
+ if (mua_wrapper && (status & 0xffff) != 0) exim_exit(EXIT_FAILURE, US"main");
}
}
}
@@ -5829,7 +5824,7 @@ moreloop:
store_reset(reset_point);
}
-exim_exit(EXIT_SUCCESS); /* Never returns */
+exim_exit(EXIT_SUCCESS, US"main"); /* Never returns */
return 0; /* To stop compiler warning */
}
diff --git a/src/src/functions.h b/src/src/functions.h
index 111e5c31c..760a9f52b 100644
--- a/src/src/functions.h
+++ b/src/src/functions.h
@@ -181,7 +181,7 @@ extern uschar *event_raise(uschar *, const uschar *, uschar *);
extern void msg_event_raise(const uschar *, const address_item *);
#endif
extern const uschar * exim_errstr(int);
-extern void exim_exit(int);
+extern void exim_exit(int, const uschar *);
extern void exim_nullstd(void);
extern void exim_setugid(uid_t, gid_t, BOOL, uschar *);
extern void exim_wait_tick(struct timeval *, int);
diff --git a/src/src/log.c b/src/src/log.c
index fd72bb1ad..32db57448 100644
--- a/src/src/log.c
+++ b/src/src/log.c
@@ -232,7 +232,7 @@ if (s1)
}
if (receive_call_bombout) receive_bomb_out(NULL, s2); /* does not return */
if (smtp_input) smtp_closedown(s2);
-exim_exit(EXIT_FAILURE);
+exim_exit(EXIT_FAILURE, NULL);
}
@@ -761,7 +761,7 @@ if (!log_buffer)
if (!(log_buffer = US malloc(LOG_BUFFER_SIZE)))
{
fprintf(stderr, "exim: failed to get store for log buffer\n");
- exim_exit(EXIT_FAILURE);
+ exim_exit(EXIT_FAILURE, NULL);
}
/* If we haven't already done so, inspect the setting of log_file_path to
@@ -958,7 +958,7 @@ if (!really_exim || log_testing_mode)
else
fprintf(log_stderr, "%s", CS log_buffer);
}
- if ((flags & LOG_PANIC_DIE) == LOG_PANIC_DIE) exim_exit(EXIT_FAILURE);
+ if ((flags & LOG_PANIC_DIE) == LOG_PANIC_DIE) exim_exit(EXIT_FAILURE, US"");
return;
}
diff --git a/src/src/moan.c b/src/src/moan.c
index 6d922a5a4..90deefc56 100644
--- a/src/src/moan.c
+++ b/src/src/moan.c
@@ -587,7 +587,7 @@ fprintf(stderr, "%d previous message%s successfully processed.\n",
fprintf(stderr, "The rest of the batch was abandoned.\n");
-exim_exit(yield);
+exim_exit(yield, US"batch");
}
diff --git a/src/src/receive.c b/src/src/receive.c
index 2d9aacd31..31402925d 100644
--- a/src/src/receive.c
+++ b/src/src/receive.c
@@ -190,7 +190,7 @@ if (STATVFS(CS path, &statbuf) != 0)
log_write(0, LOG_MAIN|LOG_PANIC, "cannot accept message: failed to stat "
"%s directory %s: %s", name, path, strerror(errno));
smtp_closedown(US"spool or log directory problem");
- exim_exit(EXIT_FAILURE);
+ exim_exit(EXIT_FAILURE, NULL);
}
*inodeptr = (statbuf.F_FILES > 0)? statbuf.F_FAVAIL : -1;
@@ -343,7 +343,7 @@ if (!already_bombing_out)
/* Exit from the program (non-BSMTP cases) */
-exim_exit(EXIT_FAILURE);
+exim_exit(EXIT_FAILURE, NULL);
}
@@ -1142,7 +1142,7 @@ if (error_handling == ERRORS_SENDER)
else
fprintf(stderr, "exim: %s%s\n", text2, text1); /* Sic */
(void)fclose(f);
-exim_exit(error_rc);
+exim_exit(error_rc, US"");
}
@@ -3324,7 +3324,7 @@ if (extract_recip && (bad_addresses != NULL || recipients_count == 0))
{
Uunlink(spool_name);
(void)fclose(data_file);
- exim_exit(error_rc);
+ exim_exit(error_rc, US"receiving");
}
}
diff --git a/src/src/smtp_in.c b/src/src/smtp_in.c
index b5839f544..b27949e35 100644
--- a/src/src/smtp_in.c
+++ b/src/src/smtp_in.c
@@ -842,7 +842,7 @@ if (!yield)
{
log_write(0, LOG_MAIN|LOG_PANIC, "string too large in smtp_printf()");
smtp_closedown(US"Unexpected error");
- exim_exit(EXIT_FAILURE);
+ exim_exit(EXIT_FAILURE, NULL);
}
/* If this is the first output for a (non-batch) RCPT command, see if all RCPTs
@@ -922,7 +922,7 @@ if (smtp_batched_input)
moan_smtp_batch(NULL, "421 SMTP command timeout"); /* Does not return */
smtp_notquit_exit(US"command-timeout", US"421",
US"%s: SMTP command timeout - closing connection", smtp_active_hostname);
-exim_exit(EXIT_FAILURE);
+exim_exit(EXIT_FAILURE, US"receiving");
}
@@ -946,7 +946,7 @@ if (smtp_batched_input)
moan_smtp_batch(NULL, "421 SIGTERM received"); /* Does not return */
smtp_notquit_exit(US"signal-exit", US"421",
US"%s: Service not available - closing connection", smtp_active_hostname);
-exim_exit(EXIT_FAILURE);
+exim_exit(EXIT_FAILURE, US"receiving");
}
diff --git a/src/src/transports/smtp.c b/src/src/transports/smtp.c
index 14cfde72a..3b4aea192 100644
--- a/src/src/transports/smtp.c
+++ b/src/src/transports/smtp.c
@@ -3510,10 +3510,10 @@ propagate it from the initial
if ((pid = fork()))
{
DEBUG(D_transport) debug_printf("proxy-prox final-pid %d\n", pid);
- _exit(pid ? EXIT_FAILURE : EXIT_SUCCESS);
+ _exit(pid < 0 ? EXIT_FAILURE : EXIT_SUCCESS);
}
smtp_proxy_tls(sx.buffer, sizeof(sx.buffer), pfd[0], sx.ob->command_timeout);
- exim_exit(0);
+ exim_exit(0, US"TLS proxy");
}
}
#endif