GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — linuxKernelRoot/testRoot/testRoot.h at master · anylayer/linuxKernelRoot Expand file tree/ Copy pathtestRoot.hMore file actions 50 lines (46 loc) · 1.11 KB / Copy pathtestRoot.hFile metadata and controls50 lines (46 loc) · 1.11 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 #include <stdio.h> #include <stdlib.h> #include <string.h> #include <dirent.h> int find_cmdline_process(const char* target_cmdline) { int id; pid_t pid = -1; DIR* dir; FILE *fp; char filename[32]; char cmdline[256]; struct dirent * entry; dir = opendir("/proc"); if (dir == NULL) return -1; while ((entry = readdir(dir)) != NULL) { // 如果读取到的是"."或者".."则跳过,读取到的不是文件夹名字也跳过 if ((strcmp(entry->d_name, ".") == 0) || (strcmp(entry->d_name, "..") == 0)) { continue; } else if (entry->d_type != DT_DIR) { continue; } else if (strspn(entry->d_name, "1234567890") != strlen(entry->d_name)) { continue; } id = atoi(entry->d_name); if (id != 0) { sprintf(filename, "/proc/%d/cmdline", id); fp = fopen(filename, "r"); if (fp) { fgets(cmdline, sizeof(cmdline), fp); fclose(fp); //TRACE("[+] find %d process cmdline: %s\n", id, cmdline); if (strstr(cmdline, target_cmdline)) { /* process found */ pid = id; break; } } } } closedir(dir); return pid; } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |