[lug] Strange stderr redirection

Daniel Webb lists at danielwebb.us
Sat Jan 24 01:05:04 MST 2004


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




More information about the LUG mailing list