From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31282 invoked by alias); 19 Jun 2013 17:37:54 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 31238 invoked by uid 48); 19 Jun 2013 17:37:50 -0000 From: "dje at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug driver/57652] [4.7/4.8/4.9 Regression] collect2 does not clean up temporary files Date: Wed, 19 Jun 2013 17:37:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: driver X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: error-recovery X-Bugzilla-Severity: normal X-Bugzilla-Who: dje at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.9.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-06/txt/msg01032.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57652 --- Comment #2 from David Edelsohn --- Prototype patch to use atexit. PR driver/57652 * collect2.c (collect_atexit): New. (collect_exit): Directly call exit. (main): Register collect_atexit with atexit. Index: collect2.c =================================================================== --- collect2.c (revision 200203) +++ collect2.c (working copy) @@ -367,7 +367,7 @@ /* Delete tempfiles and exit function. */ void -collect_exit (int status) +collect_atexit (void) { if (c_file != 0 && c_file[0]) maybe_unlink (c_file); @@ -395,12 +395,13 @@ maybe_unlink (lderrout); } - if (status != 0 && output_file != 0 && output_file[0]) - maybe_unlink (output_file); - if (response_file) maybe_unlink (response_file); +} +void +collect_exit (int status) +{ exit (status); } @@ -970,6 +971,9 @@ signal (SIGCHLD, SIG_DFL); #endif + if (atexit (collect_atexit) != 0) + fatal_error ("atexit failed"); + /* Unlock the stdio streams. */ unlock_std_streams ();