AC_FUNC_FORK
AC_CHECK_FUNCS([memmove setenv],
[],[AC_MSG_ERROR([function is required])])
+AC_CHECK_FUNCS([execvpe])
dnl Thanks to gperftools' configure.ac (https://code.google.com/p/gperftools).
AC_MSG_CHECKING([for __builtin_expect])
update_environment();
return real_execvp(file, argv);
}
+
+#ifdef HAVE_EXECVPE
+extern char **environ;
+int execvpe(char const *file, char * const argv[], char * const envp[]) {
+ /* Fake the environment so we can reuse execvp(). */
+ environ = (char **)envp;
+
+ return execvp(file, argv);
+}
+#endif
#include <config.h>
+/* For execvpe(). */
+#define _GNU_SOURCE
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
execvp(argv[0], args);
return EXIT_FAILURE;
+
+#ifdef HAVE_EXECVPE
+ /* execvpe(3), but not testing the p(ath) part */
+ } else if (!skip--) {
+ char *args[] = { argv0, NULL };
+ char *envp[] = { "TEST=54", ldpreload, NULL };
+
+ execvpe(argv[0], args, envp);
+ return EXIT_FAILURE;
+ } else if (!skip--) {
+ char *args[] = { argv0, "foo", "bar", NULL };
+ char *envp[] = { "TEST=55", ldpreload, NULL };
+
+ execvpe(argv[0], args, envp);
+ return EXIT_FAILURE;
+#else
+ /* Fake output to let the test pass. */
+ } else if (!skip--) {
+ puts("argv[0] = |./example_exec|");
+ puts("environ[0] = |TEST=54|");
+ puts("environ[2] = |COLORED_STDERR_FDS=2,|");
+ puts("");
+ puts("argv[0] = |./example_exec|");
+ puts("argv[1] = |foo|");
+ puts("argv[2] = |bar|");
+ puts("environ[0] = |TEST=55|");
+ puts("environ[2] = |COLORED_STDERR_FDS=2,|");
+ puts("");
+#endif
}
printf("Done.\n");
environ[1] = |FOO=|
environ[3] = |COLORED_STDERR_FDS=2,|
+argv[0] = |./example_exec|
+environ[0] = |TEST=54|
+environ[2] = |COLORED_STDERR_FDS=2,|
+
+argv[0] = |./example_exec|
+argv[1] = |foo|
+argv[2] = |bar|
+environ[0] = |TEST=55|
+environ[2] = |COLORED_STDERR_FDS=2,|
+
Done.