Email or username:

Password:

Forgot your password?
Top-level
Ramin Honary

@abcdw As I read this documentation, my understand is that pipes are ordinary POSIX file descriptors, so you are probably responsible for closing them if you create them with the POSIX system calls.

However if you create a Scheme "port" object from a pipe, it seems like (from the manual) that the port object will automatically close the pipe when it is garbage collected:

>

> "A file descriptor can be extracted from a port and a new port can be created from a file descriptor. However a file descriptor is just an integer and the garbage collector doesn’t recognize it as a reference to the port. If all other references to the port were dropped, then it’s likely that the garbage collector would free the port, with the side-effect of closing the file descriptor prematurely.

> "To assist the programmer in avoiding this problem, each port has an associated revealed count which can be used to keep track of how many times the underlying file descriptor has been stored in other places. If a port’s revealed count is greater than zero, the file descriptor will not be closed when the port is garbage collected. A programmer can therefore ensure that the revealed count will be greater than zero if the file descriptor is needed elsewhere."

1 comment
Andrew Tropin

@ramin_hal9001 Oh, I missed those two paragraphs, thank you! :)

Go Up