Skip to content

Commit 9270e88

Browse files
author
Wayne Davison
committed
Save first filename and linenum in case exit_cleanup() recurses.
1 parent 2907af4 commit 9270e88

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

cleanup.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,18 @@ pid_t cleanup_child_pid = -1;
9898
NORETURN void _exit_cleanup(int code, const char *file, int line)
9999
{
100100
static int cleanup_step = 0;
101-
static int exit_code = 0;
101+
static int exit_code = 0, exit_line = 0;
102+
static const char *exit_file = NULL;
102103
static int unmodified_code = 0;
103104

104105
SIGACTION(SIGUSR1, SIG_IGN);
105106
SIGACTION(SIGUSR2, SIG_IGN);
106107

107-
if (exit_code) /* Preserve first error code when recursing. */
108+
if (exit_code) { /* Preserve first exit info when recursing. */
108109
code = exit_code;
110+
file = exit_file;
111+
line = exit_line;
112+
}
109113

110114
/* If this is the exit at the end of the run, the server side
111115
* should not attempt to output a message (see log_exit()). */
@@ -118,6 +122,8 @@ NORETURN void _exit_cleanup(int code, const char *file, int line)
118122
#include "case_N.h" /* case 0: cleanup_step++; */
119123

120124
exit_code = unmodified_code = code;
125+
exit_file = file;
126+
exit_line = line;
121127

122128
if (output_needs_newline) {
123129
fputc('\n', stdout);

0 commit comments

Comments
 (0)