This is the mail archive of the
guile@cygnus.com
mailing list for the Guile project.
Re: Using the fd's underlying guile fports
- To: Gary Houston <ghouston@easynet.co.uk>
- Subject: Re: Using the fd's underlying guile fports
- From: Ian Grant <I.A.N.Grant@damtp.cam.ac.uk>
- Date: Mon, 28 Jun 1999 08:57:59 +0100 (BST)
- cc: guile@cygnus.com
On 27 Jun 1999, Gary Houston wrote:
> | > Could you use a mutex?
> | >
> | > The revealed count indicates whether the port owns its descriptor.
> | > If the count is greater than 0 then the descriptor shouldn't be
> | > closed when the port is gc'd (currently implemented by not gc'ing the
> | > port, but that's not required now.)
> | >
> |
> | I don't think a mutex is any use. It's a problem within any single thread:
> | at any time where it is possible for the fd to be used directly, it
> | mustn't be used by the scheme port code. I want the fd to be legitimately
> | borrowed from the port and returned some time later.
>
> I see, you have your own port type and want to keep the FILE * around
> in its data structure.
No. I want to borrow the fd from an already-open guile fport and give it
to some third-party code which will use it. I implement two procedures,
(pg:trace port) and (pg:untrace). After a scheme program calls pg:trace
and before it calls pg:untrace, I want any access to the port to generate
a scheme error. This requires a borrowed-the-fd count for each fport and
the checking of this value before any of the ptobfuns are called.
The reason for wanting this is to save re-implementation of all the fopen/
popen code.
Ian