1 #include <stdio.h> 2 #include <string.h> 3 #include <unistd.h> 4 5 int main(int argc,char ** argv)6main (int argc, char **argv) 7 { 8 lldb_enable_attach(); 9 10 int do_crash = 0; 11 int do_wait = 0; 12 13 int idx; 14 for (idx = 1; idx < argc; idx++) 15 { 16 if (strcmp(argv[idx], "CRASH") == 0) 17 do_crash = 1; 18 if (strcmp(argv[idx], "WAIT") == 0) 19 do_wait = 1; 20 } 21 printf("PID: %d END\n", getpid()); 22 23 if (do_wait) 24 { 25 int keep_waiting = 1; 26 while (keep_waiting) 27 { 28 printf ("Waiting\n"); 29 sleep(1); // Stop here to unset keep_waiting 30 } 31 } 32 33 if (do_crash) 34 { 35 char *touch_me_not = (char *) 0; 36 printf ("About to crash.\n"); 37 touch_me_not[0] = 'a'; 38 } 39 printf ("Got there on time and it did not crash.\n"); 40 return 0; 41 } 42