diff options
author | David Edelsohn <dje.gcc@gmail.com> | 2013-06-19 23:51:05 +0000 |
---|---|---|
committer | David Edelsohn <dje@gcc.gnu.org> | 2013-06-19 19:51:05 -0400 |
commit | e1f9340b007679e863f99d26c29fd6ee2ddbd92e (patch) | |
tree | 577f4229ae37691c56e97e8f33c2bef3c116bbfc /gcc/collect2.c | |
parent | e3f9e0acec78644ef45ec984b062c856fc53a9e0 (diff) | |
download | gcc-e1f9340b007679e863f99d26c29fd6ee2ddbd92e.zip gcc-e1f9340b007679e863f99d26c29fd6ee2ddbd92e.tar.gz gcc-e1f9340b007679e863f99d26c29fd6ee2ddbd92e.tar.bz2 |
re PR driver/57652 (collect2 does not clean up temporary files)
PR driver/57652
* collect2.c (collect_atexit): New.
(collect_exit): Delete.
(main): Register collect_atexit with atexit.
(collect_wait): Change collect_exit to exit.
(do_wait): Same.
* collect2.h (collect_exit): Delete.
* tlink.c (do_tlink): Rename exit to ret. Change collect_exit to exit.
From-SVN: r200226
Diffstat (limited to 'gcc/collect2.c')
-rw-r--r-- | gcc/collect2.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/gcc/collect2.c b/gcc/collect2.c index b1eafb8..43b9def 100644 --- a/gcc/collect2.c +++ b/gcc/collect2.c @@ -366,8 +366,8 @@ static void scan_prog_file (const char *, scanpass, scanfilter); /* Delete tempfiles and exit function. */ -void -collect_exit (int status) +static void +collect_atexit (void) { if (c_file != 0 && c_file[0]) maybe_unlink (c_file); @@ -395,13 +395,8 @@ collect_exit (int status) maybe_unlink (lderrout); } - if (status != 0 && output_file != 0 && output_file[0]) - maybe_unlink (output_file); - if (response_file) maybe_unlink (response_file); - - exit (status); } @@ -970,6 +965,9 @@ main (int argc, char **argv) signal (SIGCHLD, SIG_DFL); #endif + if (atexit (collect_atexit) != 0) + fatal_error ("atexit failed"); + /* Unlock the stdio streams. */ unlock_std_streams (); @@ -1816,7 +1814,7 @@ collect_wait (const char *prog, struct pex_obj *pex) error ("%s terminated with signal %d [%s]%s", prog, sig, strsignal(sig), WCOREDUMP(status) ? ", core dumped" : ""); - collect_exit (FATAL_EXIT_CODE); + exit (FATAL_EXIT_CODE); } if (WIFEXITED (status)) @@ -1832,7 +1830,7 @@ do_wait (const char *prog, struct pex_obj *pex) if (ret != 0) { error ("%s returned %d exit status", prog, ret); - collect_exit (ret); + exit (ret); } if (response_file) |