From: Ken Kleiner <ken () cs ! uml ! edu>
To: tru64-unix-managers
Subject: bug in fgets?
Date: Mon, 27 Nov 2000 15:28:39 +0000 [thread overview]
Message-ID: <97533885112495.tru64-unix-managers.marc@archive.invalid> (raw)
Hello...
I am trying to determine if there is a bug in fgets - Compaq Tru64 5.0a.
The attached code gets stuck in an infinite loop since fgets never
returns null and/or is not reading end of file.
This does properly compile and run right on other unix boxes, such as
linux with gcc.
Has anybody seen any information on this or experienced this? Thanks
in advance....also please let me know if this is not an appropriate post
to this list.
CODE -------
/*
*
* This example code demonstrates a bug with fgets() when using
* the fork() system call. fgets() never returns NULL when it hits
* the end of file, and therefore causes an infinite loop.
*
* OSF1 V5.0 1094 alpha
*/
#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
int main(int argc, char **argv) {
FILE *fin;
char buf[80];
fin = fopen("/etc/passwd", "r");
while (fgets(buf, 80, fin) != NULL) {
printf ("%s", buf);
}
return 0;
}
--
Ken Kleiner
System Manager
Computer Science Department
Umass Lowell
voice : 978 934 3645
fax : 978 934 3551
ken@cs.uml.edu
reply other threads:[~2000-11-27 15:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox