[Rcpp-devel] How to define a function called when R exited

Tim Keitt tkeitt at utexas.edu
Wed May 7 15:56:38 CEST 2014


On Tue, May 6, 2014 at 11:53 AM, Jerome MARQUET
<jerome.marquet at lixoft.net>wrote:

>  Hello,
>
> I am building a package "myModule" and would like to define a function
> that will be called when R is exited.
>
> So I defined a function
>
> *RcppExport void R_unload_mlxComputeR(DllInfo *info)*
> *{*
> *    // Do sthg*
> *}*
>
>
> and I observe that it is called when dyn.unload(myModule) is called. But
> the function is not called when R is exited. I wonder if there is a similar
> function (like R_exit_packgName or R_quit_packageName) that is called when
> R is exited ?
>

A workaround would be to register a finalizer with onexit=TRUE on a dummy
object. See reg.finalizer.

THK


>
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>



-- 
http://www.keittlab.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20140507/21deedb5/attachment.html>


More information about the Rcpp-devel mailing list