From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18342 invoked by alias); 10 Jan 2002 07:29:59 -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 18189 invoked from network); 10 Jan 2002 07:29:55 -0000 Received: from unknown (HELO freya.inter.net.il) (192.114.186.14) by sources.redhat.com with SMTP; 10 Jan 2002 07:29:55 -0000 Received: from zaretsky ([192.116.55.139]) by freya.inter.net.il (Mirapoint) with ESMTP id BDR46768; Thu, 10 Jan 2002 09:29:38 +0200 (IST) Date: Wed, 09 Jan 2002 23:29:00 -0000 From: "Eli Zaretskii" To: ac131313@cygnus.com Message-Id: <2593-Thu10Jan2002092708+0200-eliz@is.elta.co.il> X-Mailer: emacs 21.1.50 (via feedmail 8 I) and Blat ver 1.8.9 CC: msnyder@redhat.com, gdb@sources.redhat.com, drow@mvista.com In-reply-to: <3C3CE214.5060502@cygnus.com> (message from Andrew Cagney on Wed, 09 Jan 2002 19:36:36 -0500) Subject: Re: When do cleanups happen? Reply-to: Eli Zaretskii References: <20020109151622.A842@nevyn.them.org> <3C3CC1CD.798D57DB@redhat.com> <20020109181030.B6397@nevyn.them.org> <3C3CD52D.E01410D2@redhat.com> <3C3CE214.5060502@cygnus.com> X-SW-Source: 2002-01/txt/msg00079.txt.bz2 > Date: Wed, 09 Jan 2002 19:36:36 -0500 > From: Andrew Cagney > > > > 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: Andrew, if Michael got confused by this, our docs needs work. So I suggest to add the nice explanations below to gdbint.texinfo, as the first step towards a remedy. There's a section about cleanups there where these explanations will fit nicely. > 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 > > > > > >