delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/06/18/02:19:12

Date: Wed, 18 Jun 1997 09:17:46 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Nate Eldredge <eldredge AT ap DOT net>
cc: djgpp AT delorie DOT com, DJ Delorie <dj AT delorie DOT com>
Subject: Re: Possible misbehavior of write
In-Reply-To: <199706171649.JAA19455@adit.ap.net>
Message-ID: <Pine.SUN.3.91.970618091650.23726A-100000@is>
MIME-Version: 1.0

On Tue, 17 Jun 1997, Nate Eldredge wrote:

> Is there a "correct" thing for write() to do when passed a null buffer? This
> code:
> 
> write(fd,NULL,count);
> 
> ...assuming reasonable values for fd and count, under Linux returns -1 and
> sets errno to EFAULT ("Bad address"). Under djgpp, however, it sends a
> SIGSEGV. Is this correct? What does POSIX / ANSI have to say?

It is generally preferred to have functions return EFAULT instead of
crashing.  It's just that doing this test in each and every library
function would really slow down the programs.  I suggest you submit
the necessary patches anyhow.

I don't have POSIX handy (ANSI doesn't know about EFAULS or SIGSEGV,
and `write' is non-ANSI anyway, so ANSI is irrelevant), therefore I
don't know what's POSIX policy on these.  DJ?

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019