Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA
Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!brl-tgr!tgr!cottrell@NBS-VMS.ARPA
From: cottrell@NBS-VMS.ARPA (COTTRELL, JAMES)
Newsgroups: net.unix-wizards
Subject: Syscall Return Values
Message-ID: <2411@brl-tgr.ARPA>
Date: Thu, 24-Oct-85 17:03:10 EDT
Article-I.D.: brl-tgr.2411
Posted: Thu Oct 24 17:03:10 1985
Date-Received: Sat, 26-Oct-85 04:21:39 EDT
Sender: news@brl-tgr.ARPA
Lines: 31

/*
> I thought that every SYSTEM CALL returned -1 on error.

Make that MOST system calls. The idea is to return an out-of-band value
of the same type. Other considerations apply. For example, typical code
goes like: `if (syscall(args) == ERROR) die(why);'. Success falls thru.
Since Zero is returned for success on many syscalls that return only
pass/fail, the `== ERROR' may be left out. Less readable tho.

> For example, read
> returns -1 if you give it a fid that hasn't been opened, is not readable etc.
> EOF is NOT considered an error, and is signalled by a 0 return. 

True enuf. However, both of these values are `int's, & readily 
comparable without casts. Minus One is not a legal file descriptor.

> Thus SHMOP
> returning -1 on an error would be consistent with all other system calls.

Consistent but stupid. What was being returned was a pointer (to either
a char or some struxure). The obvious choice is to return NULL, which is
a legal value of the same type. Minus One is not of type `pointer to 
something'. It requires explicit casts both in the calling AND called
funxions. Consistency is occaisionally not appropriate. I happen to
think that TPC's IPC mechanism is thrown together rather poorly.

System V is a trademark of The Phone Company

	jim		cottrell@nbs
*/
------