* When do cleanups happen? [not found] ` <20020109181030.B6397@nevyn.them.org> @ 2002-01-09 15:46 ` Michael Snyder 2002-01-09 16:36 ` Andrew Cagney 0 siblings, 1 reply; 4+ messages in thread From: Michael Snyder @ 2002-01-09 15:46 UTC (permalink / raw) To: gdb; +Cc: Daniel Jacobowitz 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. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: When do cleanups happen? 2002-01-09 15:46 ` When do cleanups happen? Michael Snyder @ 2002-01-09 16:36 ` Andrew Cagney 2002-01-09 23:29 ` Eli Zaretskii 0 siblings, 1 reply; 4+ messages in thread From: Andrew Cagney @ 2002-01-09 16:36 UTC (permalink / raw) To: Michael Snyder; +Cc: gdb, Daniel Jacobowitz > 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: When do cleanups happen? 2002-01-09 16:36 ` Andrew Cagney @ 2002-01-09 23:29 ` Eli Zaretskii 2002-01-10 10:00 ` Andrew Cagney 0 siblings, 1 reply; 4+ messages in thread From: Eli Zaretskii @ 2002-01-09 23:29 UTC (permalink / raw) To: ac131313; +Cc: msnyder, gdb, drow > 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 > > > > > > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: When do cleanups happen? 2002-01-09 23:29 ` Eli Zaretskii @ 2002-01-10 10:00 ` Andrew Cagney 0 siblings, 0 replies; 4+ messages in thread From: Andrew Cagney @ 2002-01-10 10:00 UTC (permalink / raw) To: Eli Zaretskii; +Cc: msnyder, gdb, drow > > 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. Yes (and thanks). Andrew ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2002-01-10 18:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[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 ` When do cleanups happen? Michael Snyder
2002-01-09 16:36 ` Andrew Cagney
2002-01-09 23:29 ` Eli Zaretskii
2002-01-10 10:00 ` Andrew Cagney
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox