UC07文件夹操作,进程管理.docx

  1. 1、本文档共7页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
UC07文件夹操作,进程管理

文件夹操作 drwxr-xr-x 2 ubuntu ubuntu 4096 2016-10-12 09:10 uc06 权限: r 读 w 写 x 通过 添加文件权限 文件夹的内容是什么? 文件夹中的内容就是文件夹中的文件或者文件夹; opendir(3) #include <sys/types.h> #include <dirent.h> DIR *opendir(const char *name); 功能:打开一个文件夹 参数: name 打开文件夹得名字 返回值: NULL 代表失败 errno被设置 返回一个指向文件夹流首地址 closedir #include <sys/types.h> #include <dirent.h> int closedir(DIR *dirp); 功能:关闭文件夹 参数: dirp:opendir的返回值 返回值: 成功 返回0; 失败 返回-1 errno被设置 readdir #include <dirent.h> struct dirent *readdir(DIR *dirp); 功能:读取文件夹内容 参数: dirp:opendir的返回值 struct dirent { ino_t d_ino; /* inode number */ off_t d_off; /* offset to the next dirent */ unsigned short d_reclen; /* length of this record */ unsigned char d_type; /* type of file; not supportedby all file system types */ char d_name[256]; /* filename */ }; 返回值: 如果返回NULL,代表失败errno被设置,或者到达了文件的末尾,errno不会被设置; 成功返回struct dirent 结构体地址; 杂项 chmod函数(权限) #include <sys/stat.h> int chmod(const char *path, mode_t mode); 功能: 参数: 返回值: link函数 #include <unistd.h> int link(const char *oldpath, const char *newpath); 功能:给文件起一个新的名字 参数: 返回值: unlink函数 #include <unistd.h> int unlink(const char *pathname); 功能: 参数: 返回值: symlink函数 #include <unistd.h> int symlink(const char *oldpath, const char *newpath); 功能:创建软连接 参数: 返回值: mkdir函数 #include <sys/stat.h> #include <sys/types.h> int mkdir(const char *pathname, mode_t mode); rename函数 #include <stdio.h> int rename(const char *oldpath, const char *newpath); 功能: 文件总结: open read write close mmap dup 进程管理的基础 linux下所有应用进程,是以树状组织的; pstree命令: 所有的进程之间是以父子或者兄弟组织的; init 进程的pid = 1,是所有进程树的根; ps -aux 查看进程 任何获取程序中获取自己的pid getpid函数 #include <sys/types.h> #include <unistd.h> pid_t getpid(void); 功能:获取进程的pid 参数:void 返回值: pid_t getppid(void); 举例:获取自己的的pid----------------------------------------------------------------------->>>> 在程序中任何创建新的进程: 使用fork系统调

文档评论(0)

2017ll + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档