On Mar 12 20:39, Corinna Vinschen wrote: > On Mar 11 16:05, Kaz Kylheku wrote: > > We can reproduce the problem with just file streams using > > a much simpler program: > > > > #include > > > > int main(void) > > { > > FILE *out = fopen("file", "w+"); > > setvbuf(out, (char *) NULL, _IOLBF, 0); > > getc(out); > > clearerr(out); > > fseek(out, 0, SEEK_SET); > > putc('a', out); > > putc('b', out); > > putc('c', out); > > putc('d', out); > > putc('e', out); > > putc('\n', out); > > fclose(out); > > return 0; > > } > > > > The contents of file end up being "\n": one empty > > line, instead of "abcde\n": > > > > $ cat file > > > > $ > > Thanks for the testcase. I can reproduce the issue and I see where the > problem occurs, but I'm still puzzled. Comparing the code in our newlib > C library with its BSD counterparts, I could swear the same behaviour > happens on OpenBSD as well. If not (which needs testing), I wonder why > and where newlib's actually different. Right now I don't see the > difference. I do now. Basically it's setvbuf screwing up the internal flags in the FILE structure. I took the liberty to update newlib's setvbuf to the OpenBSD version locally and I'm going to apply my patches to newlib soon. I'll provide a new 2.5.0 test release of Cygwin with this patch tomorrow or early next week. Thanks again for the testcase, Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat