From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <97533885112495.tru64-unix-managers.marc@archive.invalid> From: Ken Kleiner Date: Mon, 27 Nov 2000 15:28:39 +0000 To: tru64-unix-managers Subject: bug in fgets? X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=97533885112495 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 #include #include 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