Пример #1
0
bool DummyUnixSandbox::run(const std::string& command, const std::vector<std::string>& args) {
    BoxLocker locker(this, "run_lock");
    if (!locker.has_lock()) return false;
    if (!pre_fork_hook()) return false;
    pid_t box_pid;
    int ret = pipe(comm);
    if (ret == -1) {
        error(4, serror("Error opening pipe to child process"));
        return false;
    }
    if ((box_pid = fork()) != 0) {
        if (box_pid == -1) {
            error(4, serror("fork"));
            return false;
        }
        close(comm[1]);
        bool ret = box_checker(box_pid);
        if (!cleanup_hook()) return false;
        return ret;
    } else {
        close(comm[0]);
        if (!post_fork_hook()) exit(1);
        box_inner(command, args);
    }
    error(253, "If you read this, something went very wrong");
    return false;
}
int check_all(int *sudoku)
{
  int i;
  // Check Sudoku
  for (i=0;i<9;i++)
    {
      if((file_checker(sudoku,i)))
	return 1;
    }
  for (i=0;i<9;i++)
    {
      if((column_checker(sudoku,i)))
	return 1;
    }
  for (i=0;i<9;i++)
    {
      if(box_checker(sudoku,i+1))
	return 1;
    }
  return 0;
}