Process Run time information

Hello,

I am working on Sun Solaris 5.7. I am trying to read the running time of a process through a C program.

One way I am reading it is by using the command ps -<pid> -f

The other way is from the struct psinfo_t which is there under /proc/pid/psinfo.

However, the two times are different. The time read from the shell using ps -<pid> -f appears to be more realistic.

Can someone please tell me which one to rely on ?

regards,
Murali

"ps -<pid> -f" is not legal. I only get an error message. Maybe you mean "ps -f <pid>"? But anyway, if a process needs to find out its own cpu usage, it should invoke the times() system call.