set the file mode creation mask, umask, for a process
#include <sys/types.h> #include <sys/stat.h> mode_t qnx_umask( pid_t pid, mode_t cmask );
The qnx_umask() function sets the file mode creation mask of process pid to cmask, and returns the previous value of the mask. Only the file permission bits (as defined in <sys/stat.h>) are used. If pid is zero, the current process is used.
Note that qnx_umask() only works on local pids, and not on vids. |
The process's file mode creation mask is used during open(), creat(), mkdir() and mkfifo() calls to turn off permission bits in the mode argument supplied. Bit positions set in cmask are cleared in the mode of the created file.
The previous value of the file mode creation mask. On error, -1 is returned and errno is set.
/* * Set the umask to RW for owner,group; R for other */ #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> void main() { mode_t omask; mode_t nmask; nmask = S_IRUSR | S_IWUSR | /* owner read write */ S_IRGRP | S_IRGRP | /* group read write */ S_IROTH; /* other read */ omask = qnx_umask( 0, nmask ); printf( "mask changed from %o to %o\n", omask, nmask ); }
QNX
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | Yes, but modifies errno |
Thread | Yes |
chmod(), creat(), errno, mkdir(), mkfifo(), open(), umask()