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: Thu, 20 Feb 1997 22:59:49 -0600	[thread overview]
Message-ID: <86c8258a9fa258f8ba09aaef4ae7fa79.axp-list@archive.invalid> (raw)
In-Reply-To: <gaf@zk3.dec.com>

On Feb 18, 11:14am, Jerry Feldman wrote:
> Subject: Re: fclose() (fwd)
>
> > I just checked and Linux and Digital Unix both do the same thing.  Heres
> > the program:
> Not quite. On Digital Unix, I change %x to %lx. Pointers are 64 bits.
> > #include <stdio.h>
> > #include <stdlib.h>
> >
> > int main(void)
> > {
> >     int i;
> >     for(i=0; i<3; i++) {
> >         FILE *f = fopen("/dev/null","r");
> >         printf("f = %lx\n", f);
> >         fclose(f);
> >     }
> >     return 0;
> > }
> >
> > and here is the Digital Unix output:
> sauron:assem [1528%] a.out
> f = 3ffc0080348
> f = 3ffc0080380
> f = 3ffc0080380
> --

That's incredibly stupid. Is this a /dev/null trick ("read all you want,
there's plenty of nothing for you"). Let's say I open /etc/passwd three times
and start reading records from each (but not necessarily synchronized; f1 reads
20 bytes,
f2 reads 30 bytes, f3 lseeks to the end of file - 50 bytes) There's no way
these three pointers can be to the same address; there's no excuse for
fclose()ing
one automagically closing another (esp. if you fclose it twice, because, well,
you're a fool, but you have a license to be a fool on the wall)

-- 
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-21  4:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <gaf@zk3.dec.com>
1997-02-21  4:59 ` Bryan W. Headley [this message]
1997-08-18 16:21 ` Question on using manual monitor/kbd switch Dave Gavin
1997-02-22  1:02 fclose() (fwd) Eric Smith
     [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
     [not found] <jlnance@avanticorp.com>
1997-02-17 21:36 ` Bryan W. Headley
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