From ce7be03af53c49830df952693ee4ee2935cb37f3 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Tue, 3 Nov 2009 16:17:28 -0800 Subject: [PATCH] (SIGAR-187) implement proc_exe on AIX --- src/os/aix/aix_sigar.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/os/aix/aix_sigar.c b/src/os/aix/aix_sigar.c index bac4491f..c15e4ad6 100644 --- a/src/os/aix/aix_sigar.c +++ b/src/os/aix/aix_sigar.c @@ -949,7 +949,33 @@ int sigar_proc_fd_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) { - return SIGAR_ENOTIMPL; + int len; + char buffer[8192]; + struct procsinfo pinfo; + + pinfo.pi_pid = pid; + + if (getargs(&pinfo, sizeof(pinfo), + buffer, sizeof(buffer)) != 0) + { + return errno; + } + /* XXX argv[0] might be relative */ + len = strlen(buffer); + SIGAR_SSTRCPY(procexe->name, buffer); + + (void)SIGAR_PROC_FILENAME(buffer, pid, "/cwd"); + + if ((len = readlink(buffer, procexe->cwd, + sizeof(procexe->cwd)-1)) < 0) + { + return errno; + } + procexe->cwd[len] = '\0'; + + procexe->root[0] = '\0'; + + return SIGAR_OK; } static int sigar_proc_modules_local_get(sigar_t *sigar,