linuxprocessprocfs

When the column values for UID and GID fields in /proc/<pid>/status file will differ


Here is the output of a sample /proc/pid/status file.

From the procfs(5) Man page, found that those are Real, Effective, Saved and FileSystem UIDs

Uid:    998     998     998     998
Gid:    996     996     996     996

Here all are showing same values.

So, in any chance those four columns will show different UIDs. Especially among Real, Effective and Filesystem UIDs.


Solution

  • Taking this as a question:

    So, in any chance those four columns will show different UIDs.

    Yes. Subject to various limitations, processes can change their effective and saved UIDs and GIDs. This is what the setuid(), setgid(), seteuid(), and setegid() functions do.

    The filesystem uid and gid are Linux-specific features that are used mainly, if not entirely, in the context of NFS (see filesystem uid and gid in linux). These can be manipulated with setfsuid() and setfsgid(), subject, again, to limitations.

    For most processes, all the UIDs will the same and all the GIDs will be the same, but it is conceivable that they would all be different. It is a function of the behavior of the process.