octave-maintainers
[Top][All Lists]
Advanced

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

Re: System file-descriptors of pipe file-ids?


From: Olaf Till
Subject: Re: System file-descriptors of pipe file-ids?
Date: Mon, 25 Jun 2007 08:45:23 +0200
User-agent: Mutt/1.5.13 (2006-08-11)

On Fri, Jun 22, 2007 at 01:58:20PM -0400, John W. Eaton wrote:
> 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.

Thank you for the explanation. The attached patch implements your
suggestion.

Note that I removed the 'const' qualifier from
octave_stream_list::do_insert and octave_stream_list::insert without
knowing the consequences. It was necessary because of the
ocatve_stream::file_number () call in the first of these functions.

The three changed files are separately diff'ed against current
(24.06.07) CVS.

Olaf

Attachment: oct-stream.h.patch
Description: Text Data

Attachment: oct-stream.cc.patch
Description: Text Data

Attachment: ChangeLog.patch
Description: Text Data


reply via email to

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