Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Jim Nance <jlnance@avanticorp.com>
Subject: Re: fclose() (fwd)
Date: Mon, 17 Feb 1997 16:18:30 -0500 (EST)	[thread overview]
Message-ID: <4bdbd83256c02930fb498bc5b3702d73.axp-list@archive.invalid> (raw)

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

             reply	other threads:[~1997-02-17 21:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-02-17 21:18 Jim Nance [this message]
     [not found] <jlnance@avanticorp.com>
1997-02-17 21:36 ` fclose() (fwd) Bryan W. Headley
  -- strict thread matches above, loose matches on Subject: below --
1997-02-17 22:55 Stephen Williams
     [not found] <9702171536.ZM1175@davros.bwh.com>
1997-02-18 12:21 ` Jim Nance
     [not found] <9702181221.AA02768@halfpint.rtp.avanticorp.com>
1997-02-18 16:14 ` Jerry Feldman
     [not found] <gaf@zk3.dec.com>
1997-02-21  4:59 ` Bryan W. Headley
1997-02-22  1:02 Eric Smith
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