handle proc_exe.name for self process

This commit is contained in:
Doug MacEachern 2004-07-30 02:37:01 +00:00
parent 5213a822f6
commit 43768bac66
1 changed files with 6 additions and 1 deletions

View File

@ -782,8 +782,13 @@ int sigar_proc_exe_get(sigar_t *sigar, sigar_pid_t pid,
procexe->name[0] = '\0'; procexe->name[0] = '\0';
/* Pgrab would return G_SELF error */
if (pid == sigar_pid_get(sigar)) { if (pid == sigar_pid_get(sigar)) {
/*XXX*/ /* XXX: dunno if this will always work? */
char *exe = getenv("_");
if (exe) {
SIGAR_STRNCPY(procexe->name, exe, sizeof(procexe->name));
}
} }
else { else {
status = sigar_pgrab(sigar, pid, SIGAR_FUNC, &phandle); status = sigar_pgrab(sigar, pid, SIGAR_FUNC, &phandle);