[procps] Re: newlib, ps fix

  • From: Craig Small <csmall-procps@xxxxxxxxxx>
  • To: procps@xxxxxxxxxxxxx
  • Date: Sun, 30 Aug 2015 23:17:09 +1000

On Sun, Aug 30, 2015 at 10:05:23PM +1000, Craig Small wrote:

I'll attach my test program. I'm probably doing something wrong but it
means the library should be saying what and not crashing about it
either.
Hmm, not sure how we can actually test for this, library was expecting
an array, I sent an int. I now have the reap part of the library
working ok as a test and getting sensible results too. Excuse the
hard-coded positions in the printf, I'll fix them later.

- Craig

--
Craig Small (@smallsees) http://enc.com.au/ csmall at : enc.com.au
Debian GNU/Linux http://www.debian.org/ csmall at : debian.org
GPG fingerprint: 5D2F B320 B825 D939 04D2 0519 3938 F96B DF50 FEA5
#include <stdio.h>
#include <proc/pids.h>
#include <include/c.h>

int main(int argc, char *argv[])
{
struct procps_pidsinfo *info=NULL;
struct pids_reap *reap;
int i;
enum pids_item items[] = {
PROCPS_PIDS_ID_TGID, PROCPS_PIDS_ID_SESSION, PROCPS_PIDS_CMD};


if (procps_pids_new(&info, 3, items) < 0)
xerr(EXIT_FAILURE, "problem with pids_new");
printf("pids_new ok\n");
if ( (reap = procps_pids_reap(info, PROCPS_REAP_TASKS_ONLY)) == NULL)
xerr(EXIT_FAILURE, "problem with pids_reap");
printf("reap ok total: %d sleep: %d\n", reap->counts.total,
reap->counts.sleeping);
for (i=0; i < reap->counts.total; i++) {
printf("proc: %d is %s\n",
PROCPS_PIDS_VAL(0, s_int, reap->stacks[i]),
PROCPS_PIDS_VAL(2, str, reap->stacks[i]));
}

return EXIT_SUCCESS;
}

Other related posts: