示例#1
0
 void MetaProcessor::MaybeRedirectOutputRAII::pop() {
   if (m_isCurrentlyRedirecting & kSTDOUT) {
     unredirect(m_MetaProcessor->m_backupFDStdout, STDOUT_FILENO, stdout);
   }
   if (m_isCurrentlyRedirecting & kSTDERR) {
     unredirect(m_MetaProcessor->m_backupFDStderr, STDERR_FILENO, stderr);
   }
 }
示例#2
0
  void MetaProcessor::MaybeRedirectOutputRAII::pop() {
    //If we have only one redirection RAII
    //only then do the unredirection.
    if (m_MetaProcessor->getRedirectionRAIILevel() != 1)
      return;

    if (m_isCurrentlyRedirecting & kSTDOUT) {
      unredirect(m_MetaProcessor->m_backupFDStdout, STDOUT_FILENO, stdout);
    }
    if (m_isCurrentlyRedirecting & kSTDERR) {
      unredirect(m_MetaProcessor->m_backupFDStderr, STDERR_FILENO, stderr);
    }
  }
示例#3
0
 MetaProcessor::MaybeRedirectOutputRAII::MaybeRedirectOutputRAII(
                                         MetaProcessor* p)
 :m_MetaProcessor(p), m_isCurrentlyRedirecting(0) {
   StringRef redirectionFile;
   if (!m_MetaProcessor->m_PrevStdoutFileName.empty()) {
     redirectionFile = m_MetaProcessor->m_PrevStdoutFileName.back();
     redirect(stdout, redirectionFile.str(), kSTDOUT);
   }
   if (!m_MetaProcessor->m_PrevStderrFileName.empty()) {
     redirectionFile = m_MetaProcessor->m_PrevStderrFileName.back();
     // Deal with the case 2>&1 and 2&>1
     if (strcmp(redirectionFile.data(), "_IO_2_1_stdout_") == 0) {
       // If out is redirected to a file.
       if (!m_MetaProcessor->m_PrevStdoutFileName.empty()) {
         redirectionFile = m_MetaProcessor->m_PrevStdoutFileName.back();
       } else {
         unredirect(m_MetaProcessor->m_backupFDStderr, STDERR_FILENO, stderr);
       }
     }
     redirect(stderr, redirectionFile.str(), kSTDERR);
   }
 }