Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!seismo!gatech!bloom-beacon!think!ames!amdcad!sun!gorodish!guy
From: guy%gorodish@Sun.COM (Guy Harris)
Newsgroups: comp.lang.c
Subject: Re: Weird syscall returns
Message-ID: <23189@sun.uucp>
Date: Fri, 10-Jul-87 14:10:49 EDT
Article-I.D.: sun.23189
Posted: Fri Jul 10 14:10:49 1987
Date-Received: Sun, 12-Jul-87 12:50:53 EDT
References: <1158@copper.TEK.COM> <6858@auspyr.UUCP> <17171@cca.CCA.COM> <428@sds.SciCom.MN.ORG>
Sender: news@sun.uucp
Lines: 23

> >     I can think of no Unix system call that doesn't return -1 on error.
> 
> What about nice()?

From the S5R3 manual page:

	DIAGNOSTICS
	     Upon successful completion, "nice" returns the new nice
	     value minus 20.  Otherwise, a value of -1 is returned and
	     "errno" is set to indicate the error.

Other versions of "nice" may just return 0 on success, but they all
return -1 on error.

You may be thinking that -1 is a legitimate return value in the S5
"name", and you're right.  This is one of several botches in the UNIX
system call interface; to check for errors from "nice", you have to
clear "errno" before making the call, and test it after making the
call.  There are other calls, such as "ptrace", where this same
problem occurs.
	Guy Harris
	{ihnp4, decvax, seismo, decwrl, ...}!sun!guy
	guy@sun.com