#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int open(const char *pathname, int flags);
Flags:
O_CREAT:如果文件不存在,则创建文件。
O_EXCL:和O_CREAT一起使用,如果该文件已经存在,则open失败。
O_TRUNC:如果文件存在,且是普通可写文件,则将该文件大小缩减为0。
O_APPEND:追加模式,内容之间添加到文件末尾。
O_SYNC:同步IO,任何对该文件的写操作都会阻塞,指定写操作在硬件上结束。
O_ASYNC:Enable signal-driven I/O: generate a signal (SIGIO by default, but this can be changed via fcntl(2))
when input or output becomes possible on this file descriptor. This feature is only available for ter-
minals, pseudo-terminals, sockets, and (since Linux 2.6) pipes and FIFOs. See fcntl(2) for further
details.
O_NOCTTY:如果文件指向一个终端设备,它不会变成该进程的终端,即使该进程目前没有终端。
O_NONBLOCK/O_NDELAY:非阻塞模式,任何对该文件的操作都不会阻塞。
http://blog.youkuaiyun.com/scarlettsp/article/details/4054230