From 2423a9d47ce78944a747eb6c0633e8ae8e2435de Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Sat, 3 May 2008 15:04:18 +0000 Subject: [PATCH] [SIGAR-101] dont try using /usr/ucb/ps unless installed --- src/os/solaris/solaris_sigar.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/os/solaris/solaris_sigar.c b/src/os/solaris/solaris_sigar.c index 9eddebef..d40be80f 100644 --- a/src/os/solaris/solaris_sigar.c +++ b/src/os/solaris/solaris_sigar.c @@ -34,6 +34,7 @@ #include #define PROC_ERRNO ((errno == ENOENT) ? ESRCH : errno) +#define SIGAR_USR_UCB_PS "/usr/ucb/ps" int sigar_os_open(sigar_t **sig) { @@ -64,7 +65,13 @@ int sigar_os_open(sigar_t **sig) sigar->use_ucb_ps = strEQ(ptr, "true"); } else { - sigar->use_ucb_ps = 1; + struct stat sb; + if (stat(SIGAR_USR_UCB_PS, &sb) < 0) { + sigar->use_ucb_ps = 0; + } + else { + sigar->use_ucb_ps = 1; + } } sigar->pagesize = 0; @@ -809,7 +816,7 @@ static int ucb_ps_args_get(sigar_t *sigar, sigar_pid_t pid, } else { snprintf(buffer, sizeof(buffer), - "/usr/ucb/ps -ww %ld", (long)pid); + SIGAR_USR_UCB_PS " -ww %ld", (long)pid); if (!(fp = popen(buffer, "r"))) { return errno;