From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18007 invoked by alias); 10 Jan 2002 00:36:43 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 17980 invoked from network); 10 Jan 2002 00:36:42 -0000 Received: from unknown (HELO localhost.cygnus.com) (24.114.42.213) by sources.redhat.com with SMTP; 10 Jan 2002 00:36:42 -0000 Received: from cygnus.com (localhost [127.0.0.1]) by localhost.cygnus.com (Postfix) with ESMTP id 79EB73CCA; Wed, 9 Jan 2002 19:36:36 -0500 (EST) Message-ID: <3C3CE214.5060502@cygnus.com> Date: Wed, 09 Jan 2002 16:36:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:0.9.7) Gecko/20020103 X-Accept-Language: en-us MIME-Version: 1.0 To: Michael Snyder Cc: gdb@sources.redhat.com, Daniel Jacobowitz Subject: Re: When do cleanups happen? References: <20020109151622.A842@nevyn.them.org> <3C3CC1CD.798D57DB@redhat.com> <20020109181030.B6397@nevyn.them.org> <3C3CD52D.E01410D2@redhat.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2002-01/txt/msg00075.txt.bz2 > Daniel Jacobowitz wrote: > [cleanups only happen if there is an error] > >> >> On Wed, Jan 09, 2002 at 02:18:53PM -0800, Michael Snyder wrote: > >> > Cleanups are always done, no later than >> > when the command is finished executing (if not earlier). > >> >> Well, the comments in utils.c are wrong, then :) > > > Hmm! Now I am confused. > > What do others think? Are cleanups cleaned-up only on error? > Or always when a command finishes? I know that I have found > that if I make a cleanup that closes a file, then I cannot close > that file myself else it will wind up being closed twice. Two styles: oc = make_cleanup (close, fd); // yes ok that is bad ....blah blah do_cleanups (oc); which always does the close using the cleanup. This is kind of like a TRY ... FINALLY .. END construct; oc = make_cleanup (close, fd); // ... ... blah blah discard_cleanups (oc); //* is that the right f name? ... blah blah close (fd); which discards the cleanups so you're free to do the close. This is kind of a TRY ... EXCEPT ... END. And then there is the truth: catch_exceptions() / catch_errors() does a cleanup. the main command loop has a do_cleanup() call. enjoy, Andrew