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: Change output stream for printf


Andrew Lunn <andrew@lunn.ch> writes:

> > Another approach would be to use fileno(stdout) to get the file
> > descriptor underneath stdout (it should be 1). close() it and then
> > dup2() the socket into that descriptor. This is how it is done in *NIX
> > and it should work in eCos. You may need to do a bit of business to
> > flush any data still in the stream buffers.
> 
> I seemed to remember something about this not working, which i why i
> did not suggest it. Now you have mentioned it, i went googling. Its
> probably worth reading the thread:
> 
> http://sources.redhat.com/ml/ecos-discuss/2003-04/msg00135.html

Yes, I recall that not working as expected. Which is why my approach
manipulates the file descriptors underneath the C library, rather than
mess with the C library itself. If this is done early on in the
program, before any output is generated, it is logically equivalent to
redirecting or pipelining a *NIX application in the shell.

-- 
Nick Garnett                    eCos Kernel Architect
http://www.ecoscentric.com/     The eCos and RedBoot experts


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


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