drd/tests/swapcontext: Improve the portability of this test further
[valgrind.git] / none / tests / execve.c
blobdb2be290dd7b517ad2bf7d95914561baf6ce1665
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
5 int main(int argc, char **argv)
7 if (argc == 1)
9 // This tests the case where argv and envp are NULL, which is easy to
10 // get wrong because it's an unusual case.
12 #if defined(VGO_solaris)
13 // Solaris requires non-NULL argv parameter
14 char *const argv_exe[] = {"true", NULL};
15 if (execve("/bin/true", argv_exe, NULL) < 0)
16 #elif defined(VGO_darwin)
17 if (execve("/usr/bin/true", NULL, NULL) < 0)
18 #else
19 if (execve("/bin/true", NULL, NULL) < 0)
20 #endif
22 perror("execve");
23 exit(1);
27 exit(0);