OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / gcc / collect2.c
index 748a3f4..8870b7c 100644 (file)
@@ -1,7 +1,7 @@
 /* Collect static initialization info into data structures that can be
    traversed by C++ initialization and finalization routines.
    Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
+   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011, 2013
    Free Software Foundation, Inc.
    Contributed by Chris Smith (csmith@convex.com).
    Heavily modified by Michael Meissner (meissner@cygnus.com),
@@ -384,8 +384,8 @@ static void scan_prog_file (const char *, scanpass, scanfilter);
 \f
 /* 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);
@@ -413,13 +413,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);
 }
 
 \f
@@ -1132,6 +1127,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 ();
 
@@ -1973,7 +1971,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))
@@ -1989,7 +1987,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)