Home | History | Annotate | Download | only in gdbserver_tests
      1 #include <stdlib.h>
      2 #include <stdio.h>
      3 #include <errno.h>
      4 #include <unistd.h>
      5 #include <sys/wait.h>
      6 int main()
      7 {
      8    int mem = 0, pid;
      9    pid = fork();
     10    if (pid == -1) {
     11       mem = 1;
     12       perror("fork");
     13       exit(1);
     14    }
     15 
     16    if (pid == 0) {
     17       int burn;
     18       for (burn = 0; burn < 100000; burn++) /* burncpu */__asm__ __volatile("":::"memory") ;
     19       if (mem == 0)
     20          exit(0);
     21       else
     22          exit(1);
     23    } else {
     24       int ret;
     25       int status;
     26       while((ret = waitpid(pid, &status, 0)) != pid) {
     27          if (errno != EINTR) {
     28             perror("waitpid");
     29             exit(1);
     30          }
     31       }
     32       mem = status;
     33    }
     34    if (mem == 0)
     35       printf("mem is zero\n");
     36 
     37    return 0;
     38 }
     39