use libproc.so to fillin the proc_exe cwd and root fields

This commit is contained in:
Doug MacEachern 2004-07-30 01:57:58 +00:00
parent f3705ac25d
commit 23f6fd91b3
2 changed files with 27 additions and 1 deletions

View File

@ -166,6 +166,8 @@ typedef void (*proc_free_func_t)(void *);
typedef void (*proc_objname_func_t)(void *, uintptr_t, const char *, size_t); typedef void (*proc_objname_func_t)(void *, uintptr_t, const char *, size_t);
typedef char * (*proc_dirname_func_t)(const char *, char *, size_t);
struct sigar_t { struct sigar_t {
SIGAR_T_BASE; SIGAR_T_BASE;
@ -213,6 +215,7 @@ struct sigar_t {
proc_grab_func_t pgrab; proc_grab_func_t pgrab;
proc_free_func_t pfree; proc_free_func_t pfree;
proc_objname_func_t pobjname; proc_objname_func_t pobjname;
proc_dirname_func_t pdirname;
}; };
#define kSTAT_uint(v, type) \ #define kSTAT_uint(v, type) \

View File

@ -431,10 +431,12 @@ static int sigar_init_libproc(sigar_t *sigar)
sigar->pgrab = (proc_grab_func_t)dlsym(sigar->plib, "Pgrab"); sigar->pgrab = (proc_grab_func_t)dlsym(sigar->plib, "Pgrab");
sigar->pfree = (proc_free_func_t)dlsym(sigar->plib, "Pfree"); sigar->pfree = (proc_free_func_t)dlsym(sigar->plib, "Pfree");
sigar->pobjname = (proc_objname_func_t)dlsym(sigar->plib, "Pobjname"); sigar->pobjname = (proc_objname_func_t)dlsym(sigar->plib, "Pobjname");
sigar->pdirname = (proc_dirname_func_t)dlsym(sigar->plib, "proc_dirname");
CHECK_PSYM(pgrab); CHECK_PSYM(pgrab);
CHECK_PSYM(pfree); CHECK_PSYM(pfree);
CHECK_PSYM(pobjname); CHECK_PSYM(pobjname);
CHECK_PSYM(pdirname);
return SIGAR_OK; return SIGAR_OK;
} }
@ -697,7 +699,28 @@ int sigar_proc_fd_get(sigar_t *sigar, sigar_pid_t pid,
int sigar_proc_exe_get(sigar_t *sigar, sigar_pid_t pid, int sigar_proc_exe_get(sigar_t *sigar, sigar_pid_t pid,
sigar_proc_exe_t *procexe) sigar_proc_exe_t *procexe)
{ {
return SIGAR_ENOTIMPL; int status;
char buffer[BUFSIZ];
if ((status = sigar_init_libproc(sigar)) != SIGAR_OK) {
return status;
}
procexe->name[0] = '\0'; /*XXX*/
(void)SIGAR_PROC_FILENAME(buffer, pid, "/cwd");
if (!sigar->pdirname(buffer, procexe->cwd, sizeof(procexe->cwd))) {
procexe->cwd[0] = '\0';
}
(void)SIGAR_PROC_FILENAME(buffer, pid, "/root");
if (!(sigar->pdirname(buffer, procexe->root, sizeof(procexe->root)))) {
procexe->root[0] = '\0';
}
return SIGAR_OK;
} }
/* from libproc.h, not included w/ solaris distro */ /* from libproc.h, not included w/ solaris distro */