X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=libinterfork%2Finterfork.c;fp=libinterfork%2Finterfork.c;h=cfdd2c475b79ae016ff470c0bb04a4dd0b358bf2;hb=97b042a3085a90b776471390a79a4e9dc02b75e9;hp=81f896e57ccb27ac2555dc0e0a3570bf13415d8b;hpb=0baa64b7b8b25348f6dc072c41408d5ee47b5007;p=ust.git diff --git a/libinterfork/interfork.c b/libinterfork/interfork.c index 81f896e..cfdd2c4 100644 --- a/libinterfork/interfork.c +++ b/libinterfork/interfork.c @@ -22,6 +22,7 @@ #include "share/usterr.h" extern void ust_fork(void); +extern void ust_potential_exec(void); pid_t fork(void) { @@ -44,3 +45,24 @@ pid_t fork(void) return retval; } + +int execve(const char *filename, char *const argv[], char *const envp[]) +{ + static int (*plibc_func)(const char *filename, char *const argv[], char *const envp[]) = NULL; + + pid_t retval; + + if(plibc_func == NULL) { + plibc_func = dlsym(RTLD_NEXT, "execve"); + if(plibc_func == NULL) { + fprintf(stderr, "libcwrap: unable to find execve\n"); + return -1; + } + } + + ust_potential_exec(); + + retval = plibc_func(filename, argv, envp); + + return retval; +}