The creat system call on UN*X creates a new file (or truncates an existing old file), opens it for writing, and returns a file descriptor to the file. The file is created with the given mode as modified by the current umask.
int creat(const char *path, mode_t mode);
Nowadays, creat is completely equivalent to opening the file with O_WRONLY | O_CREAT | O_TRUNC; as such, it is rarely used. (But the interesting name lives on in the flag O_CREAT.)
O_WRONLY | O_CREAT | O_TRUNC
The behaviour of creat is atomic. Nothing can occur between the creation of the file and its opening. This can be very useful.
The spelling is quaint. Ken Thompson is said to have said after 20 years of UNIX that, if allowed to change one thing in it, he'd "add an e".
Cre"at (kr?"?t), n. [F. crat, ultimateli fr. L. creatus created, begotten; cf. It. creato pupil, servant, Sp. criado a servant, client.] Man.
An usher to a riding master.
© Webster 1913.
Log in or register
to write something here or to contact authors.