extreme oddity, may be bash-1.1.14, may be binutils, may be kernel (?)

Steven Lembark (lembark@wrkhors.psyber.com)
Mon, 26 Jun 1995 23:11:16 -0700


using:

Linux wrkhors 1.2.10 #10 Fri Jun 23 17:36:46 PDT 1995 i486
gcc-2.6.3
binutils-2.5.2l.17
libc-5.0.9
bash-1.1.14

kernel, bash and program compiled w/ above.

wierd thing: printf's to stderr

small piece of source code:

printdate() does a printf( "%9ld : 0x%08X : %02d-%3.3s-%5d\n" ...);

puts( "min_date, max_date:" );
printdate( min_date );
printdate( max_date );

puts( "today's date:" );
printdate( today() );

puts( "test1, test2. test1 =?= test2" );
printdate( test1 );
printdate( test2 );

puts( "Sequence Tests:" );

fputs( "\nincrDay():\n", stderr );
for( tmp = min_date ; tmp ; tmp = incr(tmp) )

# gcc -O2 -Wall -ojunk date.c
# junk > junk.out 2>&1

result:

incrDay():
min_date, max_date:
1 : 0x076C1001 : 01-Jan-1900
2 : 0x0834C01F : 31-Dec-2100
today's date:
3 : 0x07CB601A : 26-Jun-1995
test1, test2. test1 =?= test2
4 : 0x07B21001 : 01-Jan-1970
5 : 0x07B21001 : 01-Jan-1970

notice that incrDay(), written after the others, is first. other
oddity, later writes (this thing checks date functions for 200 years,
*lots* of outout) seems to mix up the data when stderr and
stdout are mixed:

146816 : 0x076C1012 : 18-Jan-1900
146817 : 0x076C1011 : 17-Jan-1900
146818
incrWk():
: 0x076C1010 : 16-Jan-1900
146819 : 0x076C100F : 15-Jan-1900

no data is lost, but the buffered output was broken in half! normally,
the \n should flush things, especially w/ respect to subsequent writes.
could be bash is doing something funny, could be the libc's FILE is
screwey, could be the fd is doing somethng funny.

one other test:

junk 2>71 | tee a;

produced the same results (i.e., pipe to tee sees the same wierdness
as redirect direct to a file on disk).

any suggestions on tracking this down?

thanx,
Steve Lembark Workhorse Computing
(lembark@wrkhors.psyber.com) 1972 Ethan Ln, #38, Sacramento, CA 95825
-----------------------------------------------------------------------------
The opinions expressed here are those of this company. I am the company.
-----------------------------------------------------------------------------