From: Richard M Kreuter <kreuter@pr...> - 2008-12-11 23:53:44
Didier Verna writes:
> I just can't sem to figure out how to convert my CL stream to proper
> ioctl food... Will this be a general (with-open-file) problem, or is
> it just a problem with *standard-output* ?
Somewhere in between: it's liable to be a problem for *standard-output*,
and will never be a problem for streams inside with-open-file. It even
turns out to be documented! SBCL manual section 15.3.3 :
| Some functions accept objects such as filenames or file
| descriptors. Wherever these are specified as such in the C bindings,
| the Lisp interface accepts designators for them as specified in the
| 'Types' section above.
And section 22.214.171.124:
| A file-descriptor is a non-negative small integer.
| A file-stream is a designator for a file-descriptor: the stream's file
| descriptor is extracted.
That is, only file-streams are designators for file descriptors (the
fact that all fd-streams are file-streams is dopey, but that's a
separate issue). Instances of other type of Lisp stream aren't
designators for file descriptors. For some kinds of stream, it's pretty
clear that there really isn't any descriptor (string-streams); for other
cases, I think you can make an argument that we ought to do more than we
do (e.g., chasing down a synonym-stream's underlying stream, maybe
taking the first of a concatenated-stream's streams). In other cases,
there might not be a right thing (broadcast-streams, echo-streams,
two-way-streams). And then there's the question whether there'd ought
to be a protocol function along with the Gray Streams protocol for
So I suggest wrapping sb-posix:ioctl in something that does what you
like to get an fd given an arbitrary Lisp stream. It might not be the
right thing, but at least it'll seem right to its author. :)
Richard M Kreuter <kreuter@...> wrote:
> Didier Verna writes:
>> I just can't sem to figure out how to convert my CL stream to proper
>> ioctl food... Will this be a general (with-open-file) problem, or is
>> it just a problem with *standard-output* ?
> Somewhere in between: it's liable to be a problem for *standard-output*,
> and will never be a problem for streams inside with-open-file.
Indeed. With a with-open-file stream, I get an ENOTTY error, which is
normal ;-), but at least, the ioctl handles the stream correctly.
> So I suggest wrapping sb-posix:ioctl in something that does what you
> like to get an fd given an arbitrary Lisp stream. It might not be the
> right thing, but at least it'll seem right to its author. :)
OK, since the problem is more or less contained to *standard-output*,
I figured that I can default my stream to sb-sys:*stdout* instead. Don't
really know what I'm doing, but it works.
Resistance is futile. You will be jazzimilated.
Scientific site: http://www.lrde.epita.fr/~didier
Music (Jazz) site: http://www.didierverna.com
EPITA/LRDE, 14-16 rue Voltaire, 94276 Le Kremlin-Bicêtre, France
Tel. +33 (0)1 44 08 01 85 Fax. +33 (0)1 53 14 59 22