1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <unistd.h> 4 5 int main(int argc, char **argv) 6 { 7 if (argc == 1) 8 { 9 // This tests the case where argv and envp are NULL, which is easy to 10 // get wrong because it's an unusual case. 11 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 21 { 22 perror("execve"); 23 exit(1); 24 } 25 } 26 27 exit(0); 28 } 29