#include <dirent.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int main() {
DIR *dp;
struct dirent *entry;
dp = opendir("/proc");
if (dp) {
int i = 0;
while ((entry = readdir (dp)) != NULL) {
if ((strcmp(entry->d_name, ".") == 0) ||
(strcmp(entry->d_name, "..") == 0) ||
(atoll(entry->d_name) <= 0)) {
continue;
}
printf("d_name : %s\t", entry->d_name);
if (++i % 10 == 0) {
printf("\n");
}
}
printf("\n");
closedir(dp);
}
}
Linux 遍历读取/proc目录下的pid文件夹
最新推荐文章于 2023-02-04 15:15:30 发布