APUE-CH3 open

来源:互联网 发布:与人工智能有关的股票 编辑:程序博客网 时间:2024/05/21 02:53

#include <fcntl.h>
int open(const char *pathname, int oflag, ... /* mode_t mode */);
  • 0,1,2的打开: 由于应用程序在shell中执行,父进程shell已经打开了0,1,2,所以子进程默认这三个文件描述符是被打开的。
  • 头文件:#include <fcntl.h>, mode_t 需要<sys/type.h> <sys/stat.h>
  • pathname 支持相对路径
  • 文件对于owner具有执行chmod的权限,但是owner对文件不具有写权限,那么仍然是没法写入,在程序上表现为open的返回值为-1

原创粉丝点击