Re: Scheme-reports Digest, Vol 10, Issue 1 John Cowan (30 Oct 2010 07:00 UTC)
Re: Scheme-reports Digest, Vol 10, Issue 1 Aubrey Jaffer (30 Oct 2010 14:14 UTC)
Re: Scheme-reports Digest, Vol 10, Issue 1 Aaron W. Hsu (30 Oct 2010 22:05 UTC)
Re: Scheme-reports Digest, Vol 10, Issue 1 John Cowan (30 Oct 2010 22:46 UTC)
Re: Scheme-reports Digest, Vol 10, Issue 1 Aubrey Jaffer (30 Oct 2010 23:03 UTC)
Re: Scheme-reports Digest, Vol 10, Issue 1 John Cowan (31 Oct 2010 06:16 UTC)

Re: Scheme-reports Digest, Vol 10, Issue 1 John Cowan 31 Oct 2010 06:15 UTC

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-PrmTNUR8zL8@public.gmane.org
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