*BSD News Article 44855


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!simtel!zombie.ncsc.mil!news.mathworks.com!zib-berlin.de!news.tu-chemnitz.de!irz401!narcisa.sax.de!not-for-mail
From: j@narcisa.sax.de (J Wunsch)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: Segmentation fault on fclose()
Date: 2 Jun 1995 13:03:27 +0200
Organization: Private U**x site, Dresden.
Lines: 18
Message-ID: <3qmr5v$stq@bonnie.tcd-dresden.de>
References: <3qlr9b$ou4@seminole.gate.net> <3qlv94$blt@ns1.win.net>
Reply-To: joerg_wunsch@uriah.heep.sax.de
NNTP-Posting-Host: 192.109.108.139
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

Mark Hittinger <bugs@news.win.net> wrote:

>You will probably see this on lots of platforms.  When fout=NULL there is
>no file to close and fclose will die.  Fclose probably assumes a valid
>file descriptor :-)  This isn't FreeBSD specific.

flose()ing a NULL file pointer is not considered to be useful.  The
ANSI standard leaves it undefined, so the behaviour is implementation-
dependant.  An earlier discussion on the hackers list lead to the
conclusion that a segmentation fault is considered to be an
appropriate answer for such attempts (since it points to the
programmer's error instead of hiding it).

-- 
cheers, J"org                      private:   joerg_wunsch@uriah.heep.sax.de
                                   http://www.sax.de/~joerg/

Never trust an operating system you don't have sources for. ;-)