Date: Fri, 30 Oct 1998 22:39:02 +0100 (CET) From: Arjan de Vet <Arjan.deVet@adv.iae.nl> To: hackers@FreeBSD.ORG Subject: Possible bug in freopen()? Message-ID: <199810302139.WAA13889@adv.iae.nl>
next in thread | raw e-mail | index | archive | help
Hi, I may have found a bug in freopen() while testing INN 2.2-stable. Consider the following program: #include <stdio.h> #include <unistd.h> main () { FILE *f, *g; long i; g = fopen("/tmp/test", "a"); f = freopen("/tmp/test", "a", g); i = ftell(f); printf("%d\n", i); fprintf(f, "test"); i = ftell(f); printf("%d\n", i); close(f); } Start with an empty /tmp/test file and run the program three times consecutively. The results on BSD/OS 3.0, FreeBSD 2.2.7-stable and Solaris 2.6 are: BSDI 3.0 FreeBSD 2.2.7 Solaris ----------------------------------------------------------------------------- 0 0 0 4 4 4 0 0 4 8 4 8 0 0 8 12 4 12 Hmm... Quite different. I think Solaris shows the correct behaviour. In each case /tmp/test contains "testtesttest" after the running the program three times. Arjan -- Arjan de Vet, Eindhoven, The Netherlands <Arjan.deVet@adv.iae.nl> URL: http://www.iae.nl/users/devet/ for PGP key: finger devet@iae.nl To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199810302139.WAA13889>