int open(const char *pathname, int flags, ...);
头文件:include <sys/types.h> include <sys/stat.h> include <fcntl.h>;
pathname 文件路径;
flags 必选项一个: O_RDONLY O_WRONLY O_RDWR;
可选项:O_APPEND 追加 O_CREAT 文件不存在创建,需要提供第三个参数;
O_TRUNC 截断 O_NONBLACK 非阻塞打开;
参数3, 是由umask 和 mode共同决定;
成功调用返回文件描述符, 失败返回 -1, 同时设置error为相应的错误码
close(fd)
int close(int fd);
fd:文件描述符, 成功返回0, 失败返回-1;