daily pastebin goal
81%
SHARE
TWEET

Untitled

a guest Nov 20th, 2017 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <dirent.h>
  2. #include <errno.h>
  3. #include <sys/types.h>
  4. #include <stdio.h>
  5. #include <ctype.h>
  6. #include <string.h>
  7. #include <fcntl.h>
  8. #include <stdlib.h>
  9. #include <unistd.h>
  10.  
  11. #define BUFFER_SIZE 1024
  12.  
  13. int main(){
  14. char folder_name[254];
  15. DIR *d;
  16. char buffer[BUFFER_SIZE];
  17. struct dirent *dir;
  18. d = opendir("/proc");
  19. char s1[254];
  20.  
  21. if(d){
  22.     printf("PID             CMD \n");
  23.  
  24.     while((dir = readdir(d)) != NULL){
  25.         if(folder_name[0] > '0' && folder_name[0] < '9'){
  26.             printf("%s", dir->d_name);
  27.             strcpy(s1, "/proc/");
  28.             strcpy(s1, dir->d_name);
  29.  
  30.  
  31.         }
  32.  
  33.     }
  34. closedir(d);
  35.  
  36. }
  37.  
  38.  
  39. return 0;
  40. }
RAW Paste Data
Top