help-octave
[Top][All Lists]
Advanced

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

System file-descriptors of pipe file-ids?


From: John W. Eaton
Subject: System file-descriptors of pipe file-ids?
Date: Fri, 22 Jun 2007 13:58:20 -0400

On 22-Jun-2007, Olaf Till wrote:

| I want to make a select() call on pipes created with Octaves
| interpreted pipe() function. So I need the systems file-descriptors of
| these pipes.
| 
| As I had to learn it seems to be difficult to get file-descriptors of
| c++ streams.

As I recall, this is the reason that file objects in Octave (the
things referenced by the file ids returned from fopen, popen, etc.)
are now implemented by wrapping FILE pointers inside iostream objects.
Since there is a FILE pointer for each of these things, then it is
possible to get the corresponding file descriptor.

However, from looking at the definition of the fopen function
src/file-io.cc and the function octave_stream_list::do_insert in
src/oct-stream.cc, it appears that although the file id returned by
fopen could be the same as the underlying file desciptor, it is not.

I would consider a patch that fixed that.  Probably it would be best
to replace "Array<octave_stream> list" data member in the
octave_stream_list class with a "std::map<int, octave_stream>" object
to allow mapping from file descriptor number to octave_stream object,
then fix up all uses of "list" to accomodate this change.

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]