[Roy Harrington wants to find out the user id of a process, given its
process ID, without using ps]
Quote:> it seems that cuserid() would work, or if your on non SYSV machine
> you could do something like a getlogin() along with a getpwuid() or
> some such thing.
No, that'll give you *your* process's login name, not the user
ID of an arbitary process.
Not that I know a good way to do this... The only portable thing that
comes to mind, short of resorting to the "ps" command or, if you have
one, a /proc file system, is to have a setuid root process that cycles
through the entire possible uid_t range and, as each of these users,
does a kill(pid, 0) on the process you're interested in. Signal 0 is
non-destructive, but if the call succeeds you know you've found the
right user, and if it fails you go on checking. Ick!
Eric [Hi, Mort]