From 19e7aa64a53fd027c2b38a330f82625458b63610 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Fri, 30 Jul 2004 02:15:05 +0000 Subject: [PATCH] fillin proc_exe.name --- src/os/solaris/sigar_os.h | 8 ++++++-- src/os/solaris/solaris_sigar.c | 20 +++++++++++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/os/solaris/sigar_os.h b/src/os/solaris/sigar_os.h index 338ce8cc..8df99c9f 100644 --- a/src/os/solaris/sigar_os.h +++ b/src/os/solaris/sigar_os.h @@ -162,12 +162,15 @@ enum { typedef struct ps_prochandle * (*proc_grab_func_t)(pid_t, int, int *); -typedef void (*proc_free_func_t)(void *); +typedef void (*proc_free_func_t)(struct ps_prochandle *); -typedef void (*proc_objname_func_t)(void *, uintptr_t, const char *, size_t); +typedef void (*proc_objname_func_t)(struct ps_prochandle *, + uintptr_t, const char *, size_t); typedef char * (*proc_dirname_func_t)(const char *, char *, size_t); +typedef char * (*proc_exename_func_t)(struct ps_prochandle *, char *, size_t); + struct sigar_t { SIGAR_T_BASE; @@ -216,6 +219,7 @@ struct sigar_t { proc_free_func_t pfree; proc_objname_func_t pobjname; proc_dirname_func_t pdirname; + proc_exename_func_t pexename; }; #define kSTAT_uint(v, type) \ diff --git a/src/os/solaris/solaris_sigar.c b/src/os/solaris/solaris_sigar.c index 94f3384d..dd6bd4ed 100644 --- a/src/os/solaris/solaris_sigar.c +++ b/src/os/solaris/solaris_sigar.c @@ -431,6 +431,7 @@ static int sigar_init_libproc(sigar_t *sigar) sigar->pgrab = (proc_grab_func_t)dlsym(sigar->plib, "Pgrab"); sigar->pfree = (proc_free_func_t)dlsym(sigar->plib, "Pfree"); sigar->pobjname = (proc_objname_func_t)dlsym(sigar->plib, "Pobjname"); + sigar->pexename = (proc_exename_func_t)dlsym(sigar->plib, "Pexecname"); sigar->pdirname = (proc_dirname_func_t)dlsym(sigar->plib, "proc_dirname"); CHECK_PSYM(pgrab); @@ -742,13 +743,30 @@ int sigar_proc_exe_get(sigar_t *sigar, sigar_pid_t pid, { int status; char buffer[BUFSIZ]; + struct ps_prochandle *phandle; if ((status = sigar_init_libproc(sigar)) != SIGAR_OK) { return status; } - procexe->name[0] = '\0'; /*XXX*/ + procexe->name[0] = '\0'; + if (pid == sigar_pid_get(sigar)) { + /*XXX*/ + } + else { + status = sigar_pgrab(sigar, pid, SIGAR_FUNC, &phandle); + + if (status == SIGAR_OK) { + sigar->pexename(phandle, procexe->name, sizeof(procexe->name)); + sigar->pfree(phandle); + } + } + + if (procexe->name[0] == '\0') { + /*XXX*/ + } + (void)SIGAR_PROC_FILENAME(buffer, pid, "/cwd"); if (!sigar->pdirname(buffer, procexe->cwd, sizeof(procexe->cwd))) {