From: Bryan W. Headley <bheadley@interaccess.com>
Subject: Re: fclose()
Date: Mon, 17 Feb 1997 13:47:49 -0600 [thread overview]
Message-ID: <9702171347.ZM781@davros.bwh.com> (raw)
In-Reply-To: <richard@atheist.tamu.edu>
On Feb 17, 1:01pm, Richard Henderson wrote:
> Subject: Re: fclose()
> > fclose(fchan); /* works */
> > fclose(fchan); /* segfaults */
>
> Yep. malloc doen't like it when you free the same pointer twice.
>
> > Ok, so Who's in charge of this code, so I relay my findings?
>
> Me, I guess. This is a known occurrence. The bug, though,
> is with the program trying to fclose twice. The solution of
> course is not to do that.
>
Sometimes you can control that, sometimes you can't. Stupid example:
let's say that I, overly-conscientious guy, fclose stdin and stdout
and then do an exit(). It's exit's job to close all opened file handles,
and naturally it should try to close stdin/stdout. Should exit segv or
exit gracefully? The latter. Especially since fclose() should return
error code in rather than segv'ing.
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...
But legacy code rules, especially when practice is "sort of" backed up by API
specs.
--
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
next prev parent reply other threads:[~1997-02-17 19:47 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <richard@atheist.tamu.edu>
1996-05-09 14:55 ` gdb Eric Youngdale
1996-10-29 18:50 ` thanks to Richard : Xemacs compiled as ELF Zarmfab Software Development
1996-11-15 13:28 ` glibc snapshot 961111 binaries Zarmfab Software Development
1996-11-18 13:30 ` PLEASE HELP glibc 961111 : can't execute libm - linked programs Zarmfab Software Development
1996-11-19 11:12 ` Miquel van Smoorenburg
1996-11-26 19:15 ` binutils fun Bryan W. Headley
1996-11-26 18:54 ` Richard Henderson
1997-02-17 19:47 ` Bryan W. Headley [this message]
1997-02-17 20:04 ` fclose() Richard Henderson
1997-02-25 10:03 fclose() Uncle George
-- strict thread matches above, loose matches on Subject: below --
1997-02-25 9:52 fclose() Uncle George
[not found] <eric@brouhaha.com>
1997-02-25 4:08 ` fclose() Bryan W. Headley
1997-02-24 21:17 fclose() Craig Burley
1997-02-24 19:41 fclose() Eric Smith
[not found] <33119E2E.7313@voicenet.com>
1997-02-24 19:34 ` fclose() Richard Henderson
1997-02-24 13:57 fclose() Uncle George
[not found] <330AFE32.5C6E@voicenet.com>
1997-02-19 14:49 ` fclose() Richard Henderson
1997-02-19 17:45 ` fclose() Philip Blundell
1997-02-19 13:20 fclose() Uncle George
[not found] <19970218191335.5758.qmail@brouhaha.com>
1997-02-18 22:32 ` fclose() D. Champion
1997-02-18 19:13 fclose() Eric Smith
1997-02-18 19:11 fclose() Mark Hamstra
1997-02-18 18:06 fclose() Uncle George
[not found] <3309BA67.2168@voicenet.com>
1997-02-18 16:04 ` fclose() Richard Henderson
1997-02-18 14:19 fclose() Uncle George
[not found] <33088AF0.2FF1@voicenet.com>
1997-02-17 19:01 ` fclose() Richard Henderson
1997-02-17 16:44 fclose() Uncle George
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