* src/main.c: Ensure the stdin temp file is deleted when dying.

This commit is contained in:
Paul Smith 2022-02-26 17:17:20 -05:00
parent 40a6751abf
commit cb9ac2b0cc

View file

@ -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)