5 #include <sys/syscall.h>
6 #include <linux/limits.h>
9 static const char *fd_to_path(int fd
) {
10 static char path
[PATH_MAX
];
11 sprintf(path
,"/proc/self/fd/%d",fd
);
12 int l
= (int) readlink((char * __restrict__
) path
, path
, PATH_MAX
);
18 unsetenv("LD_PRELOAD");
19 return system(getenv("AT_CLOSE"));
21 static const char *command;
23 command = getenv("AT_CLOSE");
24 unsetenv("LD_PRELOAD");
26 fprintf(stderr,"%s\n",command);
33 //fprintf(stderr,"%s(%d,%s);\n",__func__,fd,fd_to_path(fd));
34 static int (*close_orig
)(int fd
);
36 close_orig
= dlsym(RTLD_NEXT
, "close");
38 int ret
= close_orig(fd
);
39 //int ret = syscall(SYS_close,fd);
43 int fclose(FILE *fd
) {
44 //fprintf(stderr,"%s(%d,%d,%s);\n",__func__,fileno(fd),fd,fd_to_path(fileno(fd)));
45 static int (*fclose_orig
)(FILE *fd
);
47 fclose_orig
= dlsym(RTLD_NEXT
, "fclose");
49 int ret
= fclose_orig(fd
);
This page took 0.34868 seconds and 4 git commands to generate.