[SDL] I/O problem (stdio and stderr redirection to txt files)
bob at redivi.com
Thu Mar 17 08:08:40 PST 2005
On Mar 17, 2005, at 8:26, David Olofson wrote:
> Ok, doing some research, but I'm having some trouble finding anything
> useful in all the noise on the 'net...
> On Thursday 17 March 2005 09.21, David Olofson wrote:
>> If at all possible, it would probably be best to redirect the actual
>> stdout and stderr to the "Q3A console".
> Is there any reasonably portable way of redirecting stdout and stderr
> to some sort of memory streams? (Pipes, process local stdio stuff or
> whatever; all we need is some way of getting at the data that would
> normally be written to stdout and stderr.)
No, not in ANSI C or POSIX, as far as I know. You could do something
really ugly with fork and some pipes, but that's not going to work
everywhere and it's dumb.
> Another way would be to redirect the output to two files, and have the
> console tail those. However, that requires a writable temporary file
> system. Most platforms seem to have invented a bunch of places to put
> this kind of stuff... But are there platforms without a directory for
> temporary files?
The only portable way is to not use stdio directly. You really have no
business using printf(...) if you want the output to go somewhere other
than stdout. If you do want the output to go to stdout under some
scenario(s), it's easy enough to make it go there using such an an
abstraction of stdio.
More information about the SDL