umask.2: Provide a rationale for the existence of /proc/PID/status 'Umask' field

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2016-07-18 17:10:57 +02:00
parent ac6c297c7b
commit 8a2de39c05
1 changed files with 12 additions and 0 deletions

View File

@ -117,10 +117,22 @@ inherits its parent's umask.
The umask is left unchanged by
.BR execve (2).
It is impossible to user
.BR umask ()
to fetch a process's umask without at the same time changing it.
A second call to
.BR umask ()
would then be needed to restore the umask.
The nonatomicity of these two steps provides the potential
for races in multithreaded programs.
Since Linux 4.7, the umask of any process can be viewed via the
.I Umask
field of
.IR /proc/[pid]/status .
Inspecting this field in
.IR /proc/self/status
allows a process to retrieve its umask without at the same time changing it.
The umask setting also affects the permissions assigned to POSIX IPC objects
.RB ( mq_open (3),