Created
September 3, 2011 08:01
-
-
Save siddarth/1190828 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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