How to programmatically retrieve the GID of a running process
I don't know of any portable way to do this. I thought maybe ptrace()
, but I can't see how from the manpage. Even if that works, "tracing" the other process in any way is probably unnecessarily invasive
For Linux, your suggestion to use fopen("/proc/PID/status", "r")
is about as clean and direct as you're going to get. It seems to be what gdb does.