umd/external/protobuf-2.6/gtest/fused-src/gtest/gtest-all.cc
void DeathTestImpl::ReadAndInterpretStatusByte() {
  char flag;
  int bytes_read;

  // The read() here blocks until data is available (signifying the
  // failure of the death test) or until the pipe is closed (signifying
  // its success), so it's okay to call this in the parent before
  // the child process has exited.
  do {
    bytes_read = posix::Read(read_fd(), &flag, 1);
  } while (bytes_read == -1 && errno == EINTR);

  if (bytes_read == 0) {
    set_outcome(DIED);
  } else if (bytes_read == 1) {
    switch (flag) {
      case kDeathTestReturned:
        set_outcome(RETURNED);
        break;
      case kDeathTestLived:
        set_outcome(LIVED);
        break;
      case kDeathTestInternalError:
        FailFromInternalError(read_fd());  // Does not return.
        break;
      default:
        GTEST_LOG_(FATAL) << "Death test child process reported "
                          << "unexpected status byte ("
                          << static_cast<unsigned int>(flag) << ")";
    }
  } else {
    GTEST_LOG_(FATAL) << "Read from death test child process failed: "
                      << GetLastErrnoDescription();
  }
  GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Close(read_fd()));
  set_read_fd(-1);
}
// Called in the parent process only. Reads the result code of the death
// test child process via a pipe, interprets it to set the outcome_
// member, and closes read_fd_.  Outputs diagnostics and terminates in
// case of unexpected codes.
Called in the parent process only. Reads the result code of the death
test child process via a pipe, interprets it to set the outcome_
member, and closes read_fd_.  Outputs diagnostics and terminates in
case of unexpected codes.
Called in the parent process only . Reads the result code of the death test child process via a pipe interprets it to set the outcome_ member and closes read_fd_ . Outputs diagnostics and terminates in case of unexpected codes .
void DeathTestImpl::ReadAndInterpretStatusByte() {
  char flag;
  int bytes_read;
  do {
    bytes_read = posix::Read(read_fd(), &flag, 1);
  } while (bytes_read == -1 && errno == EINTR);
  if (bytes_read == 0) {
    set_outcome(DIED);
  } else if (bytes_read == 1) {
    switch (flag) {
      case kDeathTestReturned:
        set_outcome(RETURNED);
        break;
      case kDeathTestLived:
        set_outcome(LIVED);
        break;
      case kDeathTestInternalError:
        FailFromInternalError(read_fd());  
        break;
      default:
        GTEST_LOG_(FATAL) << "Death test child process reported "
                          << "unexpected status byte ("
                          << static_cast<unsigned int>(flag) << ")";
    }
  } else {
    GTEST_LOG_(FATAL) << "Read from death test child process failed: "
                      << GetLastErrnoDescription();
  }
  GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Close(read_fd()));
  set_read_fd(-1);
}
void DeathTestImpl :: ReadAndInterpretStatusByte ( ) { char flag ; int bytes_read ; do { bytes_read = posix :: Read ( read_fd ( ) , & flag , 1 ) ; } while ( bytes_read == -1 && errno == EINTR ) ; if ( bytes_read == 0 ) { set_outcome ( DIED ) ; } else if ( bytes_read == 1 ) { switch ( flag ) { case kDeathTestReturned : set_outcome ( RETURNED ) ; break ; case kDeathTestLived : set_outcome ( LIVED ) ; break ; case kDeathTestInternalError : FailFromInternalError ( read_fd ( ) ) ; break ; default : GTEST_LOG_ ( FATAL ) << " " << " " << static_cast < unsigned int > ( flag ) << " " ; } } else { GTEST_LOG_ ( FATAL ) << " " << GetLastErrnoDescription ( ) ; } GTEST_DEATH_TEST_CHECK_SYSCALL_ ( posix :: Close ( read_fd ( ) ) ) ; set_read_fd ( -1 ) ; }
Called in the parent process only.
Called in the parent process only .
// The read() here blocks until data is available (signifying the // failure of the death test) or until the pipe is closed (signifying // its success), so it's okay to call this in the parent before // the child process has exited. // Does not return.