sets the calling process's file mode creation mask (umask) to
& 0777 (i.e., only the file permission bits of
are used), and returns the previous value of the mask.
The umask is used by
and other system calls that create files
to modify the permissions placed on newly created files or directories.
Specifically, permissions in the umask are turned off from
the mode argument to
The constants that should be used to specify
are described under
The typical default value for the process umask is
S_IWGRP | S_IWOTH
In the usual case where the
is specified as:
(octal 0666) when creating a new file, the permissions on the
resulting file will be:
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
(because 0666 & ~022 = 0644; i.e., rw-r--r--).
This system call always succeeds and the previous value of the mask
SVr4, 4.3BSD, POSIX.1-2001.
A child process created via
inherits its parent's umask.
The umask is left unchanged by
The umask setting also affects the permissions assigned to POSIX IPC objects
and Unix domain sockets
created by the process.
The umask does not affect the permissions assigned
to System V IPC objects created by the process (using