Operating System - HP-UX
1752754 Members
4625 Online
108789 Solutions
New Discussion

Getting detailed process info in C program

 
savage54
Occasional Contributor

Getting detailed process info in C program

Hello,

First post here, so if I'm in the wrong location, please redirect me to the correct one.

 

Our system is an older PA-RISC 9000/800 rp4440 running 64 bit HP-UX 11.31.

 

I am trying to locate the system calls that provide access to the detailed process information that 'ps' displays.  I have found the getpid() and getppid() calls, but those only provide PID and parent PID.  I'm wanting to see additional information such as the userid associated with the PID and/or PPID, as well as the extended command line that a process, or its parent, or its grandparent is executing.

 

I understand that some (all?) of these calls might require elevated privileges.  That is not a problem, the C program that I'm writing will be able to do setresuid() to root if necessary prior to executing the calls to get this information.

 

I know the correct system calls must be out there somewhere, probably in section 2 or maybe section 3 of the man pages, but I haven't spotted them yet.  Any help would be appreciated.

 

Thanks in advance.

4 REPLIES 4

Re: Getting detailed process info in C program

I think the pstat(2) man page will help.

You can also use the "tusc" command to trace the system calls of a process. 

E.g. "tusc -o /tmp/ps_tusc.txt ps"

This will run "ps" and trace the system-calls into /tmp/ps_tusc.txt".

Hope that helps.

I am an HPE Employee

Accept or Kudo

savage54
Occasional Contributor

Re: Getting detailed process info in C program

Thank you.  I will look into the pstat() family of calls.

 

And thank you also for the tusc command. I was familiar with strace on Linux and was surprised that I couldn't find an equivalent in HP-UX.  I tried to run 'man tusc' and got a 'No manual entry for tusc.'  Can you tell me what section of man it would normally be in?  Or where I might find it on the system?

 

Thanks.

Re: Getting detailed process info in C program

I think the tusc-tool was never part of the official OS. Not sure.

You can download it from :

http://hpux.connect.org.uk/hppd/hpux/Sysadmin/tusc-8.1/

 

 

I am an HPE Employee

Accept or Kudo

savage54
Occasional Contributor

Re: Getting detailed process info in C program

I'll have to look into the tusc utility.

 

But the pstat_*() system calls is exactly what I was looking for.  Thanks for the help.