[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Joining stdout and stderr
- From: Eduardo Ochs <eduardoochs@...>
- Date: Tue, 20 Dec 2005 12:55:08 -0300
> > Hi list - is there a way to join Lua's stdout and stderr? In all
> > the (few) ways that I've tried they kept using separate buffers,
> > so if a program sends a lot of output to stdout and aborts with an
> > error I get the error messages in the "wrong place", like this:
> This is an OS issue, not a Lua issue --- Lua just hands the data
> over to the OS's stdout and stderr implementations.
I know that in theory "io.stderr = io.stdout" should work, but it's
not working in practice... Here is exactly what I'm doing: I am at
work now, using Emacs and Lua on a Window$ box, and I save the block
below to a file, I evaluate the defun with C-x C-e and then I run M-x
c to run Lua (5.0.2) on the current file and to display the output in
a buffer called "*Lua*".
(defun c () (interactive)
(format "c:/edrx/luasocket/lua.exe %s"
(delete-region (point-min) (point-max))
io.stderr = io.stdout
for i=1,40 do print("blablablaaaaaaaaaaaa stdout: "..i) end
The error message appears after the first 4096 bytes of stdout output
and before the other 2395 bytes. If I run lua on that file in a shell
window the problem does not happen - I guess that that's because
isatty says that stdout and stderr are terminals and so no buffering
occurs. By the way, I don't know how to do something like "2>&1 |" on
W$ - actually I don't really know how to use W$, and if it weren't for
Emacs and Lua I would be xxxxed.
One nice workaround would be to change the error handler to make it
flush stdout before starting to print out things. I'll try to
experiment with some ways of doing that without needing to change the
C code, as I don't have a C compiler here...
Cheers, hints very welcome,