diff --git a/src/os/osf1/osf1_sigar.c b/src/os/osf1/osf1_sigar.c index b34a830b..9122f931 100644 --- a/src/os/osf1/osf1_sigar.c +++ b/src/os/osf1/osf1_sigar.c @@ -13,6 +13,7 @@ int sigar_os_open(sigar_t **sigar) (*sigar)->pagesize = getpagesize(); (*sigar)->boot_time = 0; (*sigar)->mhz = 0; + (*sigar)->nproc = -1; return SIGAR_OK; } @@ -140,10 +141,39 @@ int sigar_loadavg_get(sigar_t *sigar, return SIGAR_OK; } +#define PROC_ELTS 16 + int sigar_proc_list_get(sigar_t *sigar, sigar_proc_list_t *proclist) { - return SIGAR_ENOTIMPL; + struct tbl_procinfo procinfo[PROC_ELTS]; + int offset; + + if (sigar->nproc == -1) { + /* this number will not change while we are running */ + sigar->nproc = table(TBL_PROCINFO, 0, NULL, INT_MAX, 0); + } + + sigar_proc_list_create(proclist); + + for (offset=0; offsetnproc; offset+=PROC_ELTS) { + int i; + int elts = table(TBL_PROCINFO, offset, &procinfo, + PROC_ELTS, sizeof(procinfo[0])); + + for (i=0; ipi_status) { + continue; + } + + SIGAR_PROC_LIST_GROW(proclist); + + proclist->data[proclist->number++] = info->pi_pid; + } + } + + return SIGAR_OK; } int sigar_proc_stat_get(sigar_t *sigar, diff --git a/src/os/osf1/sigar_os.h b/src/os/osf1/sigar_os.h index 124d01bb..98e584e0 100644 --- a/src/os/osf1/sigar_os.h +++ b/src/os/osf1/sigar_os.h @@ -18,6 +18,7 @@ struct sigar_t { SIGAR_T_BASE; int pagesize; int mhz; + int nproc; }; #endif /* SIGAR_OS_H */