Ejemplo n.º 1
0
bool getCurrentExecPath(char *buf, size_t len)
{
	struct pst_status psts;

	if (pstat_getproc(&psts, sizeof(psts), 0, getpid()) == -1)
		return false;

	if (pstat_getpathname(buf, len, &psts.pst_fid_text) == -1)
		return false;

	return true;
}
Ejemplo n.º 2
0
int sigar_proc_exe_get(sigar_t *sigar, sigar_pid_t pid,
                       sigar_proc_exe_t *procexe)
{
#ifdef __pst_fid /* 11.11+ */
    int rc;
    struct pst_status status;

    if (pstat_getproc(&status, sizeof(status), 0, pid) == -1) {
        return errno;
    }

    rc = pstat_getpathname(procexe->cwd,
                           sizeof(procexe->cwd),
                           &status.pst_fid_cdir);
    if (rc == -1) {
        return errno;
    }

    rc = pstat_getpathname(procexe->name,
                           sizeof(procexe->name),
                           &status.pst_fid_text);
    if (rc == -1) {
        return errno;
    }

    rc = pstat_getpathname(procexe->root,
                           sizeof(procexe->root),
                           &status.pst_fid_rdir);
    if (rc == -1) {
        return errno;
    }

    return SIGAR_OK;
#else
    return SIGAR_ENOTIMPL; /* 11.00 */
#endif
}