[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme-reports] Scheme-reports Digest, Vol 10, Issue 1

Aubrey Jaffer scripsit:

> If the way you refer to file-descriptors is by number, then there is
> no way for the garbage collector to prove that a file-descriptor is no
> longer in use.

Quite so.  For this reason, the scsh Posix API keeps track of which
file descriptors have been revealed by their ports, and will not close
them when the port becomes garbage.  Similarly, if you use dup2() to
open a specific file descriptor that happens to be in use by a port,
scsh will first dup() the descriptor and change over the port to using it.

> If the garbage collector can't reclaim file-descriptors, then it
> becomes the programmer's responsibility to close file-descriptors it
> no longer uses.  Exceptions or programmer oversights result in leaked
> file-descriptors.

This can't be avoided, though, because exposed file descriptors are part
of the API; for example, you may be exec()-ing a program that expects
to find something specific on a fixed descriptor.

John Cowan      http://www.ccil.org/~cowan      cowan@x
Be yourself.  Especially do not feign a working knowledge of RDF where
no such knowledge exists.  Neither be cynical about RELAX NG; for in
the face of all aridity and disenchantment in the world of markup,
James Clark is as perennial as the grass.  --DeXiderata, Sean McGrath

Scheme-reports mailing list