user/usertests.c
void
exitwait(void)
{
  int i, pid;

  printf("exitwait test\n");

  for(i = 0; i < 100; i++){
    pid = fork();
    if(pid < 0){
      printf("fork failed\n");
      exit(1);
    }
    if(pid){
      int xstate;
      if(wait(&xstate) != pid){
        printf("wait wrong pid\n");
        exit(1);
      }
      if(i != xstate) {
        printf("wait wrong exit status\n");
        exit(1);
      }
    } else {
      exit(i);
    }
  }
  printf("exitwait ok\n");
}
// try to find any races between exit and wait
try to find any races between exit and wait
try to find any races between exit and wait
void
exitwait(void)
{
  int i, pid;
  printf("exitwait test\n");
  for(i = 0; i < 100; i++){
    pid = fork();
    if(pid < 0){
      printf("fork failed\n");
      exit(1);
    }
    if(pid){
      int xstate;
      if(wait(&xstate) != pid){
        printf("wait wrong pid\n");
        exit(1);
      }
      if(i != xstate) {
        printf("wait wrong exit status\n");
        exit(1);
      }
    } else {
      exit(i);
    }
  }
  printf("exitwait ok\n");
}
void exitwait ( void ) { int i , pid ; printf ( " \n " ) ; for ( i = 0 ; i < 100 ; i ++ ) { pid = fork ( ) ; if ( pid < 0 ) { printf ( " \n " ) ; exit ( 1 ) ; } if ( pid ) { int xstate ; if ( wait ( & xstate ) != pid ) { printf ( " \n " ) ; exit ( 1 ) ; } if ( i != xstate ) { printf ( " \n " ) ; exit ( 1 ) ; } } else { exit ( i ) ; } } printf ( " \n " ) ; }
try to find any races between exit and wait
try to find any races between exit and wait