CREAT(2)CREAT(2)NAME
creat - create a new file or rewrite an existing one
SYNOPSIS
#include <sys/file.h>
#include <sys/stat.h>
#include <fcntl.h>
int creat(const char *path, mode_t mode);
DESCRIPTION
The creat function creates a new file or prepares to rewrite an
existing file whose pathname is given by path. If the file did not
exist previously, then the file is created with permission bits set to
the value of the mode argument, modified by the process's mode mask
(see umask(2)). Also see chmod(2) for the construction of the mode
argument.
The created file is opened for writing, and its file descriptor is
returned. If the file already existed, its mode and owner remain
unchanged but it is truncated to zero length.
The function call:
creat(path, mode);
is equivalent to:
open(path, O_WRONLY | O_CREAT | O_TRUNC, mode);
RETURN VALUE
Upon successful completion, creat returns a nonnegative integer
representing the lowest numbered unused file descriptor. Otherwise,
the function returns -1 and sets errno to indicate the error.
ERRORS
See open(2) for possible error conditions and errno values.
SEE ALSOchmod(2), close(2), open(2), umask(2), write(2)4th Berkeley Distribution August 1, 1992 CREAT(2)