From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <4bdbd83256c02930fb498bc5b3702d73.axp-list@archive.invalid> X-Archive-Original-Message-ID: <9702172118.AA01238@halfpint.rtp.avanticorp.com> Date: Mon, 17 Feb 1997 16:18:30 -0500 (EST) From: Jim Nance Subject: Re: fclose() (fwd) Forwarded message: > > In professional world, I've seen far too many programs that close all > > handles at termination, regardless of whether if known that handle is > > open or not. It WOULD be nice to legislate good programming, I agree... I wonder why they bother. They all get closed when the program terminates. But thats not what I am writing about. A little gem of experience I gained under SunOS is that the code sequence: FILE *f1, *f2; f1 = fopen("file1", "r"); fclose(f1); f2 = fopen("file2", "r"); fclose(f1); /* Second close of f1 */ will close f2 when you call fclose on f1 the second time because the second fopen() returns the same pointer that the first fopen() returned. Ie the file pointers get recycled. This can be most unpleasant. I guess my point is that even if we make fclose() not crash, there is no guarantee that its going to run like the programmer intended. Will Electric Fence catch these violations? I know that Purify does and it is a nice feature. Jim -- To unsubscribe: send e-mail to axp-list-request@redhat.com with 'unsubscribe' as the subject. Do not send it to axp-list@redhat.com