mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-18 11:00:07 +00:00
(getloadavg): Fail if we cannot return as many values as the user asked for.
This commit is contained in:
parent
5a7eedfbe6
commit
b73c2df940
@ -1,5 +1,5 @@
|
|||||||
/* Get system load averages. Linux (/proc/loadavg) version.
|
/* Get system load averages. Linux (/proc/loadavg) version.
|
||||||
Copyright (C) 1999, 2000 Free Software Foundation, Inc.
|
Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -55,7 +55,10 @@ getloadavg (double loadavg[], int nelem)
|
|||||||
char *endp;
|
char *endp;
|
||||||
loadavg[i] = strtod (p, &endp);
|
loadavg[i] = strtod (p, &endp);
|
||||||
if (!endp || endp == p)
|
if (!endp || endp == p)
|
||||||
break;
|
/* This should not happen. The format of /proc/loadavg
|
||||||
|
must have changed. Don't return with what we have,
|
||||||
|
signal an error. */
|
||||||
|
return -1;
|
||||||
p = endp;
|
p = endp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user