Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: "Eli Zaretskii" <eliz@is.elta.co.il>
To: ac131313@cygnus.com
Cc: msnyder@redhat.com, gdb@sources.redhat.com, drow@mvista.com
Subject: Re: When do cleanups happen?
Date: Wed, 09 Jan 2002 23:29:00 -0000	[thread overview]
Message-ID: <2593-Thu10Jan2002092708+0200-eliz@is.elta.co.il> (raw)
In-Reply-To: <3C3CE214.5060502@cygnus.com> (message from Andrew Cagney on Wed, 09 Jan 2002 19:36:36 -0500)

> Date: Wed, 09 Jan 2002 19:36:36 -0500
> From: Andrew Cagney <ac131313@cygnus.com>
> > 
> > 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
> 
> 
> 
> 
> 
> 


  reply	other threads:[~2002-01-10  7:29 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
2002-01-09 23:29         ` Eli Zaretskii [this message]
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=2593-Thu10Jan2002092708+0200-eliz@is.elta.co.il \
    --to=eliz@is.elta.co.il \
    --cc=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