diff --git a/src/os/solaris/sigar_os.h b/src/os/solaris/sigar_os.h index 5105ee0c..fda99327 100644 --- a/src/os/solaris/sigar_os.h +++ b/src/os/solaris/sigar_os.h @@ -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 */ diff --git a/src/os/solaris/solaris_sigar.c b/src/os/solaris/solaris_sigar.c index 4fd99cb6..24e50329 100644 --- a/src/os/solaris/solaris_sigar.c +++ b/src/os/solaris/solaris_sigar.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #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';