[Previous]
[Contents]
[Next]

qnx_umask()

set the file mode creation mask, umask, for a process

Synopsis:

#include <sys/types.h>
#include <sys/stat.h>
mode_t qnx_umask( pid_t pid, mode_t cmask );

Description:

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: 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.

Returns:

The previous value of the file mode creation mask. On error, -1 is returned and errno is set.

Errors:

EPERM
Insufficient permission to set the umask for this process.
ESRCH
The pid is invalid.

Examples:

/*
 * 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 );
  }

Classification:

QNX

Safety:
Interrupt handler No
Signal handler Yes, but modifies errno
Thread Yes

See also:

chmod(), creat(), errno, mkdir(), mkfifo(), open(), umask()


[Previous]
[Contents]
[Next]