This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: sdtin/stdout/stderr redirection


Philippe Vandermersch wrote:
Jifl.

I liked your proposal because I do not have to deal with C++ but :

1)
fclose( stdout ) failed :
ASSERT FAIL: <4>dlmalloc.cxx[765]do_check_chunk() (cyg_uint8 *)p >= arenabase
ASSERT FAIL: <4>dlmalloc.cxx [ 765] do_check_chunk() (cyg_uint8 *)p >= arenabase
TRACE: <4>sched.cxx [ 705] disinherit_priority() }}RETURNING UNSET!
TRACE: <4>mutex.cxx [ 447] unlock()

Bugger, I forgot about that. fclose() is trying to free stdin, but stdin was not allocated off the heap.


2)
If I do not close it and do simply : stdout = fdopen(fd_out , "w" ) seems to succeed but printf does print anything

Ah... my guess is that the default buffering mode is full buffering, not line buffering, so you would have to set the buffering mode to _IOLBF with setvbuf().


If it's not that I'm afraid I don't know off-hand what it could be. fdopen() calles fopen_inner() in fopen.cxx, which calls a constructor just like you do below.

3)
To make it work, I had to do this in C++:

Cyg_StdioStream *StdoutStream = new Cyg_StdioStream( fd_out, Cyg_StdioStream::CYG_STREAM_WRITE, false, false, _IOLBF );
if(StdoutStream == NULL) return( ENOMEM );
stdout = (FILE *)StdoutStream;


It also works for stdin,stderr.

That's good. Although if you had a moment, it would be nice if you could have a quick poke around to see why 2) didn't work, and in particular if using setvbuf(stdout, NULL, _IOLBF, BUFSIZ); is all it takes.


Jifl
--
eCosCentric    http://www.eCosCentric.com/    The eCos and RedBoot experts
--[ "You can complain because roses have thorns, or you ]--
--[  can rejoice because thorns have roses." -Lincoln   ]-- Opinions==mine


-- Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]