fillin proc_exe.name
This commit is contained in:
parent
4e3cdb949b
commit
19e7aa64a5
|
@ -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) \
|
||||
|
|
|
@ -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,12 +743,29 @@ 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");
|
||||
|
||||
|
|
Loading…
Reference in New Issue