Re: [Rd] hook for when R quits

From: Henrik Bengtsson <hb_at_biostat.ucsf.edu>
Date: Fri, 11 Mar 2011 10:49:17 -0800

See onSessionExit() in the R.utils package, e.g.

onSessionExit(function(...) {
  cat("Bye bye world!\n");
})

quit();

Please pay attention to the Details section of help(onSessionExit); there are ways that R can exit that will not be detected/handled.

/Henrik

On Fri, Mar 11, 2011 at 10:37 AM, Michael Lawrence <lawrence.michael_at_gene.com> wrote:
> Thanks for the suggestion, but I don't think that R finalizes all of its
> objects when it quits. At least a simple test suggests that on Linux.
>
> Michael
>
> On Fri, Mar 11, 2011 at 10:19 AM, Jeffrey Ryan <jeffrey.ryan_at_lemnica.com>wrote:
>
>> Take a look at reg.finalizer.  You'd have to create an object
>> internally that would persist until R exits - and a related function
>> to handle cleanup of course.
>>
>> HTH
>> Jeff
>>
>> On Fri, Mar 11, 2011 at 12:08 PM, Michael Lawrence
>> <lawrence.michael_at_gene.com> wrote:
>> > Hi,
>> >
>> > Is there any way that a package can listen for when R quits? The Qt stuff
>> is
>> > hooking into platform-specific event loops and when those die
>> unexpectedly
>> > (from the perspective of Qt), it aborts, causing an annoying error
>> dialog.
>> > If we could catch when R is killed, we could cleanup, like we do with
>> > .onUnload.
>> >
>> > Thanks,
>> > Michael
>> >
>> >        [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > R-devel_at_r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-devel
>> >
>>
>>
>>
>> --
>> Jeffrey Ryan
>> jeffrey.ryan_at_lemnica.com
>>
>> www.lemnica.com
>>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri 11 Mar 2011 - 18:54:34 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 11 Mar 2011 - 19:20:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive