[Rd] Failed file("foo", "r") keeps file open? (PR#1333)
hb@maths.lth.se
hb@maths.lth.se
Thu, 28 Feb 2002 17:20:04 +0100 (MET)
Full_Name: Henrik Bengtsson
Version: R v1.4.0
OS: Solaris 8
Submission from: (NULL) (130.235.3.49)
When I am trying the following on Rv1.4.0 on Solaris 8, I get that the
"cannot close output sink connection":
% R --vanilla
tmpfile <- tempfile() # Create a filename that does not exist
for(k in 1:100) {
cat(k, ": ");
try(fh <- file(tmpfile, "r"))
close(file("tmp.txt", "w")) # Opens and closes a file for writing.
}
1 Error in file(tempfile(), "r") : cannot open file `/tmp/fileR70d5S167e'
2 Error in file(tempfile(), "r") : cannot open file `/tmp/fileR70d5S2781'
...
47 Error in file(tempfile(), "r") : cannot open file `/tmp/fileR70d5S345b'
Error in close.connection(file("tmp.txt", "w")) :
cannot close output sink connection
It always happens after 48 failed file openings.
To me it looks like failed 'file(tmpfile, "r")' does not correctly
clean up after itself. And since 'fh' is never assigned it can neither
be solved by a 'close(fh)'.
FYI: Doing a cat(file="tmp.txt", k") instead of the close(file(...)) call,
will produce a "sink stack is full" error.
FYI2: After the failure above, trying to call sink() will result in a
"Segmentation fault" and [R] is stopped.
Background: I ran into this problem after have been running the same
script several times over several days I eventually ran into the problem.
It was hard to identify the problem, but I believe the above example shows
the core of it and I could not track the problem further.
Unfortunately, I do not have access to R v1.4.1 for Solaris 8.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._