creat() COHERENT System Call creat() Create/truncate a file int creat(file, mode) char *file; int mode; creat creates a new file or truncates an existing file. It returns a file descriptor that identifies file for subsequent system calls. If file already exists, its contents are erased. In this case, creat ignores the specified mode; the mode of the file remains unchanged. If file did not exist previously, creat uses the mode argument to determine the mode of the new file. For a full definition of file modes, see chmod or the header file stat.h. creat masks the mode argument with the current umask, so it is common practice to create files with the maximal mode desirable. ***** Example ***** For an example of how to use this routine, see the entry for open. ***** See Also ***** chmod(), COHERENT system calls(), fopen(), open(), stat.h, STDIO ***** Diagnostics ***** If the call is successful, creat returns a file descriptor. It returns -1 if it could not create the file, typically because of insufficient system resources or protection violations. COHERENT Lexicon Page 1