Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Bryan W. Headley <bheadley@interaccess.com>
Subject: Re: fclose() (fwd)
Date: Mon, 17 Feb 1997 15:36:28 -0600	[thread overview]
Message-ID: <5de78c46509aee1450f7c6565f05ff25.axp-list@archive.invalid> (raw)
In-Reply-To: <jlnance@avanticorp.com>

On Feb 17,  4:18pm, Jim Nance wrote:
> 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.
>
Yeech! I wonder what it does with three potential file *'s. That downright
sucks; it's nice that they keep their FILE *'s in a stack

-- 
Bryan W. Headley                    Home:   bheadley@interaccess.com
211 East Pineview Drive             Office: bwh@abnamro.com
Round Lake Park, IL 60073           Phone:  847 740-1446

--
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:36 UTC|newest]

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