1826677 Members
2624 Online
109696 Solutions
New Discussion

pstat_getproc()

 
Keith Curnow
Occasional Contributor

pstat_getproc()

I have a C program that uses pstat_getproc to get process information of everything that is running on an HP-UX 11.00 system.

I am trying to convert this to run on Linux. Does anyone know what the equivelant is on Linux? Or where I can find documentation on the API interface for the "ps" command.

Thanks in advance.
--Keith
3 REPLIES 3
harry d brown jr
Honored Contributor

Re: pstat_getproc()

I'm not sure how this helps:

http://web.mit.edu/afs/sipb.mit.edu/project/sipbsrc/linux/skill-3.7/getproc.c


live free or die
harry
Live Free or Die
Santosh Nair_1
Honored Contributor

Re: pstat_getproc()

Most of that information is gathered by catting files in the /proc filesystem. There is a LPK (Linux Porting Kit) on HP's Devresources site:

http://devresource.hp.com/LPK/docs/portguideparisc.pdf

which might be of some help. I believe they talk about portin from Linux to HP but the information is probably relavent going the other way.

Hope this helps.

-Santosh
Life is what's happening while you're busy making other plans
Christopher Caldwell
Honored Contributor

Re: pstat_getproc()

Here's an example from sendmail:
/*
** Read /proc/loadavg for the load average. This is assumed to be
** in a format like "0.15 0.12 0.06".
**
** Initially intended for Linux. This has been in the kernel
** since at least 0.99.15.
*/

# ifndef _PATH_LOADAVG
# define _PATH_LOADAVG "/proc/loadavg"
# endif

int
getla()
{
double avenrun;
register int result;
FILE *fp;

fp = fopen(_PATH_LOADAVG, "r");
if (fp == NULL)
{
if (tTd(3, 1))
printf("getla: fopen(%s): %s\n",
_PATH_LOADAVG, errstring(errno));
return -1;
}
result = fscanf(fp, "%lf", &avenrun);
fclose(fp);
if (result != 1)
{
if (tTd(3, 1))
printf("getla: fscanf() = %d: %s\n",
result, errstring(errno));
return -1;
}

if (tTd(3, 1))
printf("getla(): %.2f\n", avenrun);

return ((int) (avenrun + 0.5));
}