[lug] Strange stderr redirection

Budyanto Himawan budyanto_himawan at yahoo.com
Sat Jan 24 09:39:32 MST 2004


Thats interesting. Which lines are from stdout and
which ones are from stderr?

By default stdout is line buffered and stderr is
unbuffered. You can try to use setvbuf to set stdout
to unbuffered and see what happens.


--- Daniel Webb <lists at danielwebb.us> wrote:
> When I combine stderr with stdout and save stdout to
> a file, I get a
> different result than when I just run the program
> and watch the terminal.
> I could have sworn I've done this for years and it
> always looked the
> same... and yes I have put in fflush() calls all
> over the place and this
> doesn't change.  I'm running Debian stable.
> 
> Here's examples:
> 
> >./example
> fixed int parameter = 100
> p0 = 1.111
> p1 = 15000
> p2 = 9e+20
> p4->string = test string 1
> p4->number = 23.345
> all required parameters exist
> key: "parameter 4", type: GPOINTER (type 10), value:
> 804B7EC
> key: "parameter 1", type: INT (type 1), value: 15000
> key: "parameter 3", type: DOUBLE (type 2), value:
> 9e+20
> ------------------------
> key: "parameter 1", type: INT (type 1), value: 15000
> ------------------------
> key: "parameter 1", type: INT (type 1), value: 15000
> key: "parameter 2", type: DOUBLE (type 2), value:
> 9e+20
> key: "parameter 3", type: DOUBLE (type 2), value:
> 2.222
> ------------------------
> key: "parameter 1", type: INT (type 1), value: 15000
> key: "parameter 2", type: DOUBLE (type 2), value:
> 9e+20
> ------------------------
> key: "parameter 4", type: DOUBLE (type 2), value:
> 9.876
> key: "parameter 1", type: INT (type 1), value: 15000
> key: "parameter 2", type: DOUBLE (type 2), value:
> 9e+20
> ------------------------
> return_int == 0 before subroutine3() call
> return_double == 0 before subroutine3() call
> return_int == 3 after subroutine3() call
> return_double == 3.3 after subroutine3() call
> 
> 
> >./example >tempfile 2>&1
> >cat tempfile
> key: "parameter 4", type: GPOINTER (type 10), value:
> 804B7EC
> key: "parameter 1", type: INT (type 1), value: 15000
> key: "parameter 3", type: DOUBLE (type 2), value:
> 9e+20
> ------------------------
> key: "parameter 1", type: INT (type 1), value: 15000
> ------------------------
> key: "parameter 1", type: INT (type 1), value: 15000
> key: "parameter 2", type: DOUBLE (type 2), value:
> 9e+20
> key: "parameter 3", type: DOUBLE (type 2), value:
> 2.222
> ------------------------
> key: "parameter 1", type: INT (type 1), value: 15000
> key: "parameter 2", type: DOUBLE (type 2), value:
> 9e+20
> ------------------------
> key: "parameter 4", type: DOUBLE (type 2), value:
> 9.876
> key: "parameter 1", type: INT (type 1), value: 15000
> key: "parameter 2", type: DOUBLE (type 2), value:
> 9e+20
> ------------------------
> fixed int parameter = 100
> p0 = 1.111
> p1 = 15000
> p2 = 9e+20
> p4->string = test string 1
> p4->number = 23.345
> all required parameters exist
> return_int == 0 before subroutine3() call
> return_double == 0 before subroutine3() call
> return_int == 3 after subroutine3() call
> return_double == 3.3 after subroutine3() call
> 
> Thanks for any insight,
> Daniel
> 
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List:
> http://lists.lug.boulder.co.us/mailman/listinfo/lug
> Join us on IRC: lug.boulder.co.us port=6667
channel=#colug


=====
===========================
Budyanto Himawan
budyanto_himawan at yahoo.com
===========================

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/



More information about the LUG mailing list