pread读取后不会改变读写位置
/proc/${pid}/mem 无法映射,并且 mmap函数最后一个参数 文件中的映射开始位置 必须是pagesize的证书倍,否者出错
默认情况:有效用户与实际用户一致,但设置了设置位,就可能不一样了
实际用户:执行的用户
有效用户:权限用户
获取有效用户与实际用户
uid_t getuid(void); //实际用户 uid_t geteuid(void); //有效用户
int chdir(const char *path); //切换目录
int mkdir(const char *pathname, mode_t mode);//创建目录
int rmdir(const char *pathname); //删除目录
int unlink(const char *pathname); //删除文件
mode_t umask(mode_t mask); //设置文件权限屏蔽位
int stat(const char *path, struct stat *buf); int fstat(int fd, struct stat *buf); //获取文件目录状态
DIR *opendir(const char *name); //打开文件目录,DIR为指向文件目录的指针
struct dirent *readdir(DIR *dirp); //读取文件目录
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 supported by all file system types */ char d_name[256]; /* filename */ };
int closedir(DIR *dirp); //关闭文件目录
void seekdir(DIR *dirp, long offset);
int dirfd(DIR *dirp);
int scandir(const char *dirp, // 目录名
struct dirent ***namelist, //返回目录列表
int (*filter)(const struct dirent *), // 回调函数,用来过滤目录, NULL 表示不过滤 int (*compar)(const struct dirent **, const struct dirent **)); //排序函数
//返回目录的个数
例子:
执行的程序:它能执行必定有代码->内存,文件等资源->CPU等
进程有很多数据维护:进程状态 / 进程的属性
所有的进程属性都采用结构体维护->实际上是树性数据结构
1.代码?加载到内存?分配CPU时间片?
2.进程有关的创建函数
iint system(const char *command);
建立独立进程,拥有独立的代码空间,内存空间。等待新的进程执行完毕system才返回(阻塞)
返回值与进程的返回值有关,system的返回值中8-15位存放返回值。
任何线程的返回值都不要超过255,原因就是上面一条
FILE *popen(const char *command, const char *type);
创建进程; 在父子进程之间建立一个管道
exec系列函数
fork
原文:http://www.cnblogs.com/ghostll/p/3537447.html