Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Andrew Cagney <ac131313@cygnus.com>
To: Michael Snyder <msnyder@redhat.com>
Cc: gdb@sources.redhat.com, Daniel Jacobowitz <drow@mvista.com>
Subject: Re: When do cleanups happen?
Date: Wed, 09 Jan 2002 16:36:00 -0000	[thread overview]
Message-ID: <3C3CE214.5060502@cygnus.com> (raw)
In-Reply-To: <3C3CD52D.E01410D2@redhat.com>

> 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






  reply	other threads:[~2002-01-10  0:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20020109151622.A842@nevyn.them.org>
     [not found] ` <3C3CC1CD.798D57DB@redhat.com>
     [not found]   ` <20020109181030.B6397@nevyn.them.org>
2002-01-09 15:46     ` Michael Snyder
2002-01-09 16:36       ` Andrew Cagney [this message]
2002-01-09 23:29         ` Eli Zaretskii
2002-01-10 10:00           ` Andrew Cagney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3C3CE214.5060502@cygnus.com \
    --to=ac131313@cygnus.com \
    --cc=drow@mvista.com \
    --cc=gdb@sources.redhat.com \
    --cc=msnyder@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox