This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: sdtin/stdout/stderr redirection
- From: Philippe Vandermersch <phil at equator dot com>
- To: Jonathan Larmour <jifl at eCosCentric dot com>
- Cc: ecos-discuss at sources dot redhat dot com
- Date: Wed, 09 Apr 2003 10:26:26 -0700
- Subject: Re: [ECOS] sdtin/stdout/stderr redirection
- Organization: Equator Technologies
- References: <3E887C1B.1090700@equator.com> <3E9226A4.1050606@eCosCentric.com>
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()
2)
If I do not close it and do simply : stdout = fdopen(fd_out , "w" )
seems to succeed but printf does print anything
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.
Phil.
Jonathan Larmour wrote:
Philippe Vandermersch wrote:
Hi,
I have created a filesystem over PCI which actually allows the Hosted
PCI board running eCos to access the Filesystem of the Host (running
Linux).
Now I would like to know if it is possible to redirect dynamically
eCos sdtin/stdout/stderr to some other fd than the usual 0,1,2.
My idea is to open the Linux stdin,sdtout,stderr and to affect the fd
obtained through my filesystem to the eCos ones.
Strictly the way to do this is using freopen() but that isn't fully
supported by eCos, although it wouldn't be difficult at all - just
dropped off the end several years ago now!
You could even just do it yourself using fclose() and fdopen() and
assigning to stdin - there's nothing else required AFAIK.
Jifl
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss