detect solaris version, use it to skip init_libproc if >= solaris 10.

This commit is contained in:
Doug MacEachern 2004-09-04 22:59:40 +00:00
parent 88a67ff368
commit 9a071a99a4
2 changed files with 18 additions and 5 deletions

View File

@ -172,6 +172,8 @@ typedef char * (*proc_exename_func_t)(struct ps_prochandle *, char *, size_t);
struct sigar_t {
SIGAR_T_BASE;
int solaris_version;
kstat_ctl_t *kc;
/* kstat_lookup() as needed */

View File

@ -7,6 +7,7 @@
#include <sys/proc.h>
#include <sys/swap.h>
#include <sys/stat.h>
#include <sys/utsname.h>
#include <dlfcn.h>
#define KSTAT_LIST_INIT(sigar, dev) \
@ -22,10 +23,21 @@ int sigar_os_open(sigar_t **sig)
kstat_t *ksp;
sigar_t *sigar;
int i, status;
struct utsname name;
char *ptr;
sigar = malloc(sizeof(*sigar));
*sig = sigar;
uname(&name);
if ((ptr = strchr(name.release, '.'))) {
ptr++;
sigar->solaris_version = atoi(ptr);
}
else {
sigar->solaris_version = 6;
}
sigar->pagesize = 0;
i = sysconf(_SC_PAGESIZE);
while ((i >>= 1) > 0) {
@ -827,13 +839,12 @@ int sigar_proc_exe_get(sigar_t *sigar, sigar_pid_t pid,
char buffer[BUFSIZ];
struct ps_prochandle *phandle;
if ((status = sigar_init_libproc(sigar)) != SIGAR_OK) {
return status;
if (sigar->solaris_version >= 10) {
return sigar_proc_path_exe_get(sigar, pid, procexe);
}
if (!sigar->pdirname) {
/* XXX detect solaris 10+ and skip init_libproc */
return sigar_proc_path_exe_get(sigar, pid, procexe);
if ((status = sigar_init_libproc(sigar)) != SIGAR_OK) {
return status;
}
procexe->name[0] = '\0';