Hello!
I wanto to make simple c proggram what will work like ps -e. The only colums that should be shown are PID and CMD. Thats my code:
#include <dirent.h>
#include <errno.h>
#include <sys/types.h>
#include <stdio.h>
#include <regex.h>
int main()
{
DIR *dir;
struct dirent *entry;
if ((dir = opendir("/proc")) == NULL)
perror("operation error");
else
{
printf("PID CMD\n");
while ((entry = readdir(dir)) != NULL)
printf(" %s\n", entry->d_name);
closedir(dir);
}
return 0;
}
My questins are:
1) How i can show only folders with numbers(i don't know how to implement regcomp())?
2)How to near PID write CMD (I can't glue(?) strings with path if is folder with number)?
This is an hint ... Try to develop your code starting from this! :)