The uname(3) man page suggests that checking the return value against -1 makes sense. That is not the case:
On Sun, Apr 03, 2011, Ingo Schwarze wrote to the mandoc mailing list: > > Yuri Pankov wrote: > >> uname(2) on Solaris (...) states: > >> > >> RETURN VALUES > >> Upon successful completion, a non-negative value is > >> returned. Otherwise, -1 is returned and errno is set to > >> indicate the error. > > Hm, indeed, that is not just Solaris, but POSIX, see here: > > http://pubs.opengroup.org/onlinepubs/9699919799/functions/uname.html The following trivial diff should prevent future accidents. Joachim Index: uname.3 =================================================================== RCS file: /usr/cvs/src/src/lib/libc/gen/uname.3,v retrieving revision 1.12 diff -u -p -r1.12 uname.3 --- uname.3 31 May 2007 19:19:29 -0000 1.12 +++ uname.3 18 Apr 2011 16:46:45 -0000 @@ -65,7 +65,9 @@ Machine hardware platform. .Sh RETURN VALUES If .Fn uname -is successful, 0 is returned; otherwise, \-1 is returned and +is successful, 0 is returned; otherwise, a nonzero value (on +.Ox , +\-1) is returned and .Va errno is set appropriately. .Sh ERRORS
