File: os.c-Linux-libc5

package info (click to toggle)
exim 3.36-18.2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 5,684 kB
  • ctags: 3,574
  • sloc: ansic: 52,492; sh: 1,172; perl: 577; makefile: 343
file content (33 lines) | stat: -rw-r--r-- 897 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*************************************************
*     Exim - an Internet mail transport agent    *
*************************************************/

/* Copyright (c) University of Cambridge 1997 */
/* See the file NOTICE for conditions of use and distribution. */

/* Linux-specific code. This is concatenated onto the generic
src/os.c file. Linux has an apparently unique way of getting the
load average, so we provide a unique function here, and define
OS_LOAD_AVERAGE to stop src/os.c trying to provide the function. */

#define OS_LOAD_AVERAGE

int
os_getloadavg(void)
{
char buffer[40];
double avg;
int count;
int fd = open ("/proc/loadavg", O_RDONLY);
if (fd == -1) return -1;
count = read (fd, buffer, sizeof(buffer));
(void)close (fd);
if (count <= 0) return -1;
count = sscanf (buffer, "%lf", &avg);
if (count < 1) return -1;

return (int)(avg * 1000.0);
}

/* End of os.c-Linux */