Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: Notesfiles; site hpfcls.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!lll-crg!ucdavis!ucbvax!decvax!decwrl!greipa!pesnta!hplabs!hpfcdc!hpfcls!hpfcla!rml From: rml@hpfcla.UUCP Newsgroups: net.unix-wizards Subject: Re: SHMOP (SYSV) Message-ID: <132000020@hpfcls.UUCP> Date: Mon, 28-Oct-85 20:16:00 EST Article-I.D.: hpfcls.132000020 Posted: Mon Oct 28 20:16:00 1985 Date-Received: Sun, 3-Nov-85 06:02:35 EST Organization: 28 Oct 85 18:16:00 MST Lines: 30 Shmat(2) and sbrk(2) aren't the only two calls which return pointers; look at signal(2). This is one case where NULL wouldn't do as an error return, since there are two out-of-band values for successful returns, and SIG_DFL is generally #define'd as 0. There has been some effort toward easing type-correct code here, as BSD has added #define BADSIG (int (*)())-1 and the SVID mentions under FUTURE DIRECTIONS that AT&T will add a similar macro (with a different name, SIG_ERR). Things are, at least, greatly improved from V6, when SIG_DFL and SIG_IGN didn't exist and the hard-coded constants 0 and 1 were used. From the way most UN*X implementations (including the early ones) have been written, *all* system calls return -1 on failure. Since they all pass through a common trap routine, they all pass back success/failure indication and return values via a common mechanism. The C library stubs all check this common success/failure indication and, on error, brach to common code which sets a return value of -1. Of course it would be quite easy to write the stub for a particular system call to set a return value of NULL, but this hasn't been done. It would also have been possible to have shmat return its pointer through another parameter. Realistically, there's enough code which checks sbrk and signal return values for -1 that a machine on which -1 was a valid return for either would have importability problems. I agree that at least the error return from shmat could be documented as (char *)-1. Bob Lenk {ihnp4, hplabs}!hpfcla!rml