960 |
if (!getloadavg_initialized) |
if (!getloadavg_initialized) |
961 |
{ |
{ |
962 |
# ifndef SUNOS_5 |
# ifndef SUNOS_5 |
963 |
|
|
964 |
|
pthread_mutex_lock(&Run.mutex_fd); |
965 |
|
|
966 |
channel = open ("/dev/kmem", 0); |
channel = open ("/dev/kmem", 0); |
967 |
if (channel >= 0) |
if(channel >= 0) { |
968 |
{ |
/* Set the channel to close on exec, so it does not |
969 |
/* Set the channel to close on exec, so it does not |
* litter any child's descriptor table. */ |
970 |
litter any child's descriptor table. */ |
(void)fcntl(channel, F_SETFD, fcntl(channel, F_GETFD) | FD_CLOEXEC); |
971 |
# ifdef FD_SETFD |
getloadavg_initialized = 1; |
972 |
# ifndef FD_CLOEXEC |
} |
973 |
# define FD_CLOEXEC 1 |
|
974 |
# endif |
pthread_mutex_unlock(&Run.mutex_fd); |
975 |
(void) fcntl (channel, F_SETFD, FD_CLOEXEC); |
|
|
# endif |
|
|
getloadavg_initialized = 1; |
|
|
} |
|
976 |
# else /* SUNOS_5 */ |
# else /* SUNOS_5 */ |
977 |
/* We pass 0 for the kernel, corefile, and swapfile names |
/* We pass 0 for the kernel, corefile, and swapfile names |
978 |
to use the currently running kernel. */ |
to use the currently running kernel. */ |