Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!rutgers!ames!ptsfa!ihnp4!homxb!whuts!mike
From: mike@whuts.UUCP (BALDWIN)
Newsgroups: comp.lang.c
Subject: Weird syscall returns
Message-ID: <2337@whuts.UUCP>
Date: Tue, 7-Jul-87 19:11:40 EDT
Article-I.D.: whuts.2337
Posted: Tue Jul  7 19:11:40 1987
Date-Received: Sat, 11-Jul-87 01:10:44 EDT
References: <1158@copper.TEK.COM> <6858@auspyr.UUCP> <17171@cca.CCA.COM> <1219@ius2.cs.cmu.edu>
Organization: AT&T Bell Laboratories
Lines: 26
Summary: syscalls returning <0 but other than -1

In article <1219@ius2.cs.cmu.edu>, edw@ius2.cs.cmu.edu (Eddie Wyatt) writes:
} > 
] > Almost agreed: but if a negative return code other than -1 is returned
} > the code doesn't react the same.

]     I can think of no Unix system call that doesn't return -1 on error.
} So I would say that it's a pretty good bet that "if (call(...) < 0)" and
] "if (call(...) == -1)" will act the same in all cases.

System V Release 1.0 had a PDP-11 only set of system calls collectively
named maus(2) which implemented a particularly obfusticated version of
shared memory.  Two of the calls, dismaus and switmaus, would sometimes
return -2 on successful completion.

}                                                         Though, one should
] always consult the man pages for return values if in doubt.

True, and the man pages are all very explicit.  The DIAGNOSTICS section
of (almost) every one contains the sentence, "Otherwise, a value of -1 is
returned and errno is set to indicate the error."  The man page *only*
guarantees -1, so why write potentially unportable code when it is so
*trivial* to make it correct?  It is _not_ just a style issue.
-- 
						Michael Scott Baldwin
			(not the opinions of)	AT&T Bell Laboratories
						{at&t}!whuts!mike