示例#1
0
void ShellCommand::wait()
{
	int retcode = tryWait();

	if (retcode != EXIT_SUCCESS)
	{
		switch (retcode)
		{
			case int(ReturnCodes::CANNOT_DUP_STDIN):
				throw Exception("Cannot dup2 stdin of child process", ErrorCodes::CANNOT_CREATE_CHILD_PROCESS);
			case int(ReturnCodes::CANNOT_DUP_STDOUT):
				throw Exception("Cannot dup2 stdout of child process", ErrorCodes::CANNOT_CREATE_CHILD_PROCESS);
			case int(ReturnCodes::CANNOT_DUP_STDERR):
				throw Exception("Cannot dup2 stderr of child process", ErrorCodes::CANNOT_CREATE_CHILD_PROCESS);
			case int(ReturnCodes::CANNOT_EXEC):
				throw Exception("Cannot execv in child process", ErrorCodes::CANNOT_CREATE_CHILD_PROCESS);
			default:
				throw Exception("Child process was exited with return code " + toString(retcode), ErrorCodes::CHILD_WAS_NOT_EXITED_NORMALLY);
		}
	}
}
示例#2
0
void DeterministicSchedule::wait(sem_t* sem) {
  while (!tryWait(sem)) {
    // we're not busy waiting because this is a deterministic schedule
  }
}