Date: Thu, 11 Apr 1996 23:30:23 -0600 From: Nate Williams <nate@sri.MT.net> To: stable@FreeBSD.org Subject: Critical stdio bug? Message-ID: <199604120530.XAA06324@rocky.sri.MT.net>
next in thread | raw e-mail | index | archive | help
OK, this is a *really* simply example, and it works as expected under OSF1, SCO, SunOS, and Solaris. (Not necessary the greatest list of OS's, but I had them available). However, on FreeBSD the EOF doesn't get flushed out when it's read. #include <stdio.h> int main() { char string_space[20]; do { printf("Enter a string. (EOF to exit): "); } while (scanf("%s", string_space) != EOF); printf("\n"); do { printf("Search string? (EOF to exit): "); } while (scanf("%s", string_space) != EOF); printf("\n"); return 1; } What I think should happen (and what happens on the other OS's) is that you input strings until the first EOF marker is input, and then you can input some more. The program is a silly example I'm doing to shove some data into a database and then search it later, but it doesn't work due to what I think are bugs in FreeBSD's stdio library. In FreeBSD, the EOF marker is read and appears to be left in the buffer which causes the second scanf function to read an immediate EOF and bail out of the 2nd loop. Is there something I'm missing here, or some non-obvious syscall() I need to do first? I'm running various incarnations of 2.1R and -stable here which all exhibit this behavior. Nate
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199604120530.XAA06324>