getting certain info for all processes currently running

i am writing a utility that displays information about all the running processes in the /proc directory.

I do not know how to get the following information for each of the processes in the /proc directory:

-effective user id
-effective user name
-effective group id
-effective group name
-tty
-execution time of process

I understand how to get the user id. It is from the stat struct. And to get the user name, I just pass the user id to getpwuid(). Its the same with the group id and group name.

But I''m stuck at where I can obtain the effective user id and effective group id and how to get their effective names.

Also, where can i obtain information about which terminal the current process is being controlled by? It should be in the form "/pts/#"

Also, how can i find out how long a process has been executing?

Thank you.

The /proc/<pid>/psinfo file contains the details that you require. How those details are to be extracted, probably have to read the man page in detail for that.

I checked under directory /proc/pid/ and there is no such file called "psinfo."

There is a file called stat but that does not contain the information on the effective user and group id and names.

I figured out how to get the tty.

I still don't know how to get the execution time.

is there anyone else knowledgeable on this?

/proc works differently from one os to another. Maybe you should mention which os you are using.