From patchwork Wed Jun 19 14:49:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Edelsohn X-Patchwork-Id: 252588 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id E43D72C0209 for ; Thu, 20 Jun 2013 00:49:53 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:cc:content-type; q=dns; s=default; b=LTNrf3wbM2NerPyRgw9B4ClJGcP+0Y1XEaj4kVwtRQy M0h6nLVkOBhriKXHuUBNPEwJWOiO5hPZeWMStrQUXbnwkS8Fav9h4mkAhcDm7gRC LcLVXxw9ZCgnse+qmkXQJY7vPyVEPokaGskGch2uOcz5PxaMzulGbv9bqfQnMUbg = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:cc:content-type; s=default; bh=9vE4GHX9UsoiABwyJtpcchP3ANA=; b=wtTHV6AtTeS0k+/YJ LXeYcWLM1pQa6eBKPLYfaHdK9LgMjOPKMjJIcXlBPUEnU65PLFv4qgNawQ+fp6Yz UM74rbn7V0eWgClggN8XfyzkODD5QjpwPm55GwHPfxyLg4kPvS/eBX2B5vxyDKFc 0ygcy4jPlG6aLIC6vPiMEHdu2Y= Received: (qmail 23795 invoked by alias); 19 Jun 2013 14:49:47 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 23777 invoked by uid 89); 19 Jun 2013 14:49:44 -0000 X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, SPF_PASS autolearn=ham version=3.3.1 Received: from mail-vb0-f54.google.com (HELO mail-vb0-f54.google.com) (209.85.212.54) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 19 Jun 2013 14:49:43 +0000 Received: by mail-vb0-f54.google.com with SMTP id q12so3796385vbe.27 for ; Wed, 19 Jun 2013 07:49:42 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.221.42.138 with SMTP id ty10mr602752vcb.42.1371653382058; Wed, 19 Jun 2013 07:49:42 -0700 (PDT) Received: by 10.220.118.135 with HTTP; Wed, 19 Jun 2013 07:49:41 -0700 (PDT) Date: Wed, 19 Jun 2013 10:49:41 -0400 Message-ID: Subject: [PATCH] PR/57652 collect2 temp files From: David Edelsohn To: "Myers, Joseph" Cc: GCC Patches A 2011 change to collect2 to use the standard diagnostics infrastructure broke collect2's cleanup of temp files when an error occurs. This prototype of a patch implements the minimal conversion of collect2 to use atexit(). If this is the right direction, all calls to collect_exit() can be converted to exit(). Thanks, David 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 200180) +++ 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,16 @@ maybe_unlink (lderrout); } - if (status != 0 && output_file != 0 && output_file[0]) + if (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 +974,9 @@ signal (SIGCHLD, SIG_DFL); #endif + if (atexit (collect_atexit) != 0) + fatal_error ("atexit failed"); + /* Unlock the stdio streams. */ unlock_std_streams ();