Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!decwrl!labrea!aurora!ames!sdcsvax!ucsdhub!hp-sdd!hplabs!hpcea!hpfcdc!rml From: rml@hpfcdc.HP.COM (Bob Lenk) Newsgroups: comp.lang.c Subject: Re: Re: Question on ANSI C compatibility (really return values and errno) Message-ID: <5080008@hpfcdc.HP.COM> Date: 15 Dec 87 23:30:20 GMT References: <1853@haddock.ISC.COM> Organization: HP Ft. Collins, Co. Lines: 22 >Tell me then, o POSIX gurus, whether there are still functions that can return >-1 on success (e.g. ptrace() and possibly nice())? If so, does POSIX specify >what these functions are allowed to do with errno in such a case? POSIX specifies how errors are to be checked for each function. Usually, for a function that is traditionally a system call (section 2 of UN*X) this is by checking the return value, and if it has a specific value (most often -1) errno can be checked. There is generally no specification of the effect of any successful function on errno (consider isatty(), should it set errno to ENOTTY when returning 0 as happens on many current implementations?). There is one function, readdir(), for which the same return value (NULL) may indicate an error or a certain type of success (end of file). This is sepcifically mentioned, and the correct way to program is to set errno to 0 before calling readdir() and to check its value after readdir() returns NULL. POSIX does not define ptrace() or nice(). Bob Lenk {ihnp4, hplabs}!hpfcla!rml