umask(0);
fd = open(\"/dev/null\", O_RDWR);
Here\'s man 2 umask
:
umask() sets the calling process’s file mode creatio
Citing this article:
The purpose of the umask is to allow users to influence the permissions given to newly created files and directories. Daemons should not allow themselves to be affected by this setting, because what was appropriate for the user will not necessarily be suitable for the daemon.
In some cases it may be more convenient for the umask to be set to a non-zero value. This is equally acceptable: the important point is that the daemon has taken control of the value, as opposed to merely accepting what it was given.