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: John W. Eaton
Subject: Re: System file-descriptors of pipe file-ids?
Date: Mon, 25 Jun 2007 15:07:07 -0400

On 25-Jun-2007, Olaf Till wrote:

| 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.

I applied the patch.

| 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.

OK, I don't see a reasonable way to avoid removing const here.

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

It didn't cause trouble here, but it's generally best just to use cvs
diff from the top-level source directory.  Also, since diffs for
ChangeLog entries rarely apply cleanly (there are almost always later
changes that make the context invalid) it is best to cut and paste
them into the mail message rather than sending diffs for them.

Thanks,

jwe


reply via email to

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