Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include <stdio.h>
#include <glob.h>
#include <unistd.h>
#include <assert.h>
#define PATH_SIZE 1024
#define FD_PATH "/proc/%d/fd/*.*"
int main(int argc, char **argv) {
int pid = getpid();
char path[PATH_SIZE];
sprintf(path, FD_PATH, pid);
printf("%s\n", path);
glob_t data;
assert(glob(path, 0, NULL, &data) == 0);
int i;
for(i=0; i<data.gl_pathc; i++)
printf("%s\n", data.gl_pathv[i]);
globfree(&data);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.