2021年5月3日

摘要: 文件描述符 0标准输入、1标准输出、2标准错误输出 dup2 重定向 int dup2(int oldfd,int newfd) 关闭newfd对应的文件描述符,将newfd重新指向oldfd对应的文件 复制文件描述符 int dup(int oldfd) 新返回的文件描述符指向oldfd对应的文件 阅读全文
posted @ 2021-05-03 23:53 lodger47 阅读(258) 评论(0) 推荐(0)
摘要: 对目录的操作 #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <dirent.h> #include <string.h> int count = 0; int dircount(char *dirname 阅读全文
posted @ 2021-05-03 23:16 lodger47 阅读(257) 评论(0) 推荐(0)
摘要: 获取当前工作路径 getcwd 改变工作目录 chdir 创建目录 mkdir 删除目录 rmdir 打开目录 opendir 阅读全文
posted @ 2021-05-03 17:57 lodger47 阅读(134) 评论(0) 推荐(0)
摘要: 硬链接 link(argv[1],argv[2]); 软连接 symlink(argv[1],argv[2]); 读取软连接 readlink("hello3",buf,sizeof(buf));//hello3软连接的名称,buf缓冲区 只能读取软连接 取消软连接 unlink("xxx"); 阅读全文
posted @ 2021-05-03 17:20 lodger47 阅读(539) 评论(0) 推荐(0)
摘要: #include <stdio.h> #include <unistd.h> //access判断文件权限和是否存在 int main(int argc,char *argv[]) { if(argc != 2) { printf("./a.out filename\n"); return -1; 阅读全文
posted @ 2021-05-03 16:11 lodger47 阅读(560) 评论(0) 推荐(0)
摘要: #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <string.h> #include <time.h> #include 阅读全文
posted @ 2021-05-03 15:55 lodger47 阅读(238) 评论(0) 推荐(0)
摘要: 非阻塞IO 方法一 int fd=open("/dev/tty",O_RDWR|O_NONBLOCK); 方法二 //fcntl()函数,设置非阻塞 int flags = fcntl(fd,F_GETFL); flags |= O_NONBLOCK; fcntl(fd,F_SETFL,flags) 阅读全文
posted @ 2021-05-03 13:00 lodger47 阅读(266) 评论(0) 推荐(0)
摘要: 文件IO #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> open int open(const char *pathname, int flags); int open(const char *pathname, in 阅读全文
posted @ 2021-05-03 11:53 lodger47 阅读(301) 评论(0) 推荐(0)
摘要: 有时候man xxx没出来想要的内容,有可能是没安装全man文档 sudo yum -y install man-page* 阅读全文
posted @ 2021-05-03 10:35 lodger47 阅读(92) 评论(0) 推荐(0)

导航