[Rd] check does not check that package examples remove tempdir()
William Dunlap
wdunlap at tibco.com
Thu Nov 9 01:43:05 CET 2017
I was looking at the CRAN package 'bfork-0.1.2', which exposes the Unix
fork() and waitpid() calls at the R code level, and noticed that the help
file example for bfork::fork removes R's temporary directory, the value of
tempdir(). I think it happens because the forked process shares the value
of tempdir() with the parent process and removes it when it exits.
This seems like a serious problem - should 'check' make sure that running
code in a package's examples, vignettes, etc. leaves tempdir() intact?
> dir.exists(tempdir())
[1] TRUE
> library(bfork)
> example(fork)
fork> ## create a function to be run as a separate process
fork> fn <- function() {
fork+ Sys.sleep(4)
fork+ print("World!")
fork+ }
fork> ## fork the process
fork> pid <- fork(fn)
fork> ## do work in the parent process
fork> print("Hello")
[1] "Hello"
fork> ## wait for the child process
fork> waitpid(pid)
[1] "World!"
[1] 7063
> dir.exists(tempdir())
[1] FALSE
Bill Dunlap
TIBCO Software
wdunlap tibco.com
[[alternative HTML version deleted]]
More information about the R-devel
mailing list