1、
int getpriority(int which, int who);返回一组进程的优先级
参数which和who确定返回哪一组进程的优先级1、PRIO_PROCESS,一个特定的进程,此时who的取值为进程ID
2、PRIO_PGRP,一个进程组的所有进程,此时who的取值为进程组的ID
3、PRIO_USER,一个用户拥有的所有进程,此时who的取值为实际用户ID
2、
unhide-posix思路:0-99999个进程数,逐个通过getpriority查询是否有进程的优先级,如果有则代表有该进程,那么就将进行检验,用ps 查看是否存在,如果不存在则代表有该隐藏进程
3、
命令行参数可以分为两类,一类是短选项,一类是长选项,短选项在参数前加一杠"-",长选项在参数前连续加两杠"--",如下表(ls 命令参数)所示,其中-a,-A,-b都表示短选项,--all,--almost-all, --author都表示长选项。他们两者后面都可选择性添加额外参数。比如--block-size=SIZE,SIZE便是额外的参数。
getopt函数只能处理短选项,而getopt_long函数两者都可以
int getopt(int argc, char * const argv[],const char *optstring);
int getopt_long(int argc, char * const argv[], const char *optstring, const struct option *longopts, int *longindex);
int getopt_long_only(int argc, char * const argv[], const char *optstring, const struct option *longopts, int *longindex);
4、
sysinfo是用来获取系统相关信息的结构体。
struct sysinfo {
long uptime;
/* 启动到现在经过的时间 */
unsigned long loads[3];
/* 1, 5, and 15 minute load averages */
unsigned long totalram; /* 总的可用的内存大小 */
unsigned long freeram; /* 还未被使用的内存大小 */
unsigned long sharedram; /* 共享的存储器的大小 */
unsigned long bufferram; /* 缓冲区大小 */
unsigned long totalswap; /* 交换区大小 */
unsigned long freeswap; /* 还可用的交换区大小 */
unsigned short procs; /* 当前进程数目 */
char _f[22]; /* 64字节的补丁结构 */
};/proc/sys/kernel/pid_max //最大pid数量
5、
int stat(const char *path, struct stat *buf) //获取文件信息
S_ISDIR(buf.st_mode) //是否是目录
6、
int readlink(const char * path, char * buf, size_t bufsiz);
readlink()会将参数path 的符号连接内容存到参数buf 所指的内存空间, 返回的内容不是以NULL作字符串结尾, 但会将字符串的字符数返回. 若参数bufsiz 小于符号连接的内容长度, 过长的内容会被截断.
int symlink(const char * oldpath, const char * newpath);
symlink()以参数newpath 指定的名称来建立一个新的连接(符号连接)到参数oldpath 所指定的已存在文件. 参数oldpath 指定的文件不一定要存在, 如果参数newpath 指定的名称为一已存在的文件则不会建立连接.