From: Paul Smith Date: Sat, 26 Feb 2022 22:17:20 +0000 (-0500) Subject: * src/main.c: Ensure the stdin temp file is deleted when dying. X-Git-Tag: 4.3.90~94 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cb9ac2b0ccd02ced98b32e66952b98b6d40dfe9d;p=thirdparty%2Fmake.git * src/main.c: Ensure the stdin temp file is deleted when dying. --- diff --git a/src/main.c b/src/main.c index 206e3b33..80059110 100644 --- a/src/main.c +++ b/src/main.c @@ -296,6 +296,10 @@ char cmd_prefix = '\t'; unsigned long command_count = 1; +/* Remember the name of the batch file from stdin. */ + +static char *stdin_nm = 0; + /* The usage output. We write it this way to make life easier for the @@ -1067,7 +1071,6 @@ int main (int argc, char **argv, char **envp) #endif { - static char *stdin_nm = 0; int makefile_status = MAKE_SUCCESS; struct goaldep *read_files; PATH_VAR (current_directory); @@ -2595,6 +2598,8 @@ main (int argc, char **argv, char **envp) if (stdin_nm && unlink (stdin_nm) < 0 && errno != ENOENT) perror_with_name (_("unlink (temporary file): "), stdin_nm); + stdin_nm = NULL; + /* If there were no command-line goals, use the default. */ if (goals == 0) { @@ -3583,6 +3588,12 @@ die (int status) if (print_version_flag) print_version (); + /* Get rid of a temp file from reading a makefile from stdin. */ + if (stdin_nm && unlink (stdin_nm) < 0 && errno != ENOENT) + perror_with_name (_("unlink (temporary file): "), stdin_nm); + + stdin_nm = NULL; + /* Wait for children to die. */ err = (status != 0); while (job_slots_used > 0)