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 { struct sigar_t {
SIGAR_T_BASE; SIGAR_T_BASE;
int solaris_version;
kstat_ctl_t *kc; kstat_ctl_t *kc;
/* kstat_lookup() as needed */ /* kstat_lookup() as needed */

View File

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