[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: getloadavg and errno
From: |
Bruno Haible |
Subject: |
Re: getloadavg and errno |
Date: |
Tue, 15 Feb 2011 11:51:57 +0100 |
User-agent: |
KMail/1.9.9 |
Hi Paul, Jim,
> + errno = 0; /* Don't be misled if it doesn't set errno.
> */
> + loads = getloadavg (avg, 3);
> + if (loads == -1)
> + {
> + perror ("Skipping test; load average not supported");
> + return 77;
> + }
This assignment to errno, followed by the use of errno when getloadavg()
failed, brings up a question: Is getloadavg() supposed to set errno when it
fails or not?
The specification in lib/getloadavg.c indicates that "no":
/* Put the 1 minute, 5 minute and 15 minute load averages
into the first NELEM elements of LOADAVG.
Return the number written (never more than 3, but may be less than NELEM),
or -1 if an error occurred. */
In this case the test should use fputs, not perror.
Or if the answer is "yes", then the specification should say so, and the
assignment to errno in the test should be removed.
Bruno
--
In memoriam Matija Gubec <http://en.wikipedia.org/wiki/Matija_Gubec>
Re: getloadavg and errno,
Bruno Haible <=
Re: getloadavg on Solaris 2.6, Bruno Haible, 2011/02/17
Re: getloadavg on IRIX, Bruno Haible, 2011/02/17
Re: getloadavg and platforms, Bruno Haible, 2011/02/17