Home | History | Annotate | Download | only in gdbserver_tests
      1 #include <signal.h>
      2 #include <stdio.h>
      3 #include <stdlib.h>
      4 #include <string.h>
      5 #include <unistd.h>
      6 
      7 int
      8 main (int argc, char **argv)
      9 {
     10   fprintf(stderr, "starting ...\n");
     11 
     12   // Three ways of going away...
     13   if (argc > 1)
     14     {
     15       // Explicit exit() with exit code.
     16       if (strcmp (argv[1], "exit") == 0)
     17 	{
     18 	  fprintf(stderr, "exiting ...\n");
     19 	  exit (1);
     20 	}
     21 
     22       // Get killed by a signal.
     23       if (strcmp (argv[1], "abort") == 0)
     24 	{
     25 	  fprintf(stderr, "aborting ...\n");
     26 	  kill(getpid(), SIGABRT);
     27 	}
     28     }
     29 
     30   // And finally, just return from main with success.
     31   fprintf(stderr, "returning ...\n");
     32   return 0;
     33 }
     34