void InitConsole() { #ifdef _WIN_ALL // We want messages like file names or progress percent to be printed // immediately. Use only in Windows, in Unix they can cause wprintf %ls // to fail with non-English strings. setbuf(stdout,NULL); setbuf(stderr,NULL); // Detect if output is redirected and set output mode properly. // We do not want to send Unicode output to files and especially to pipes // like '|more', which cannot handle them correctly in Windows. // In Unix console output is UTF-8 and it is handled correctly // when redirecting, so no need to perform any adjustments. StdoutRedirected=IsRedirected(STD_OUTPUT_HANDLE); StderrRedirected=IsRedirected(STD_ERROR_HANDLE); StdinRedirected=IsRedirected(STD_INPUT_HANDLE); #ifdef _MSC_VER if (!StdoutRedirected) _setmode(_fileno(stdout), _O_U16TEXT); if (!StderrRedirected) _setmode(_fileno(stderr), _O_U16TEXT); #endif #endif }
void wxExecuteData::OnExit(int exitcode_) { // Remove this process from the hash list of child processes that are // still open as soon as possible to ensure we don't process it again even // if another SIGCHLD happens. if ( !ms_childProcesses.erase(pid) ) { wxFAIL_MSG(wxString::Format(wxS("Data for PID %d not in the list?"), pid)); } exitcode = exitcode_; #if wxUSE_STREAMS if ( IsRedirected() ) { // Read the remaining data in a blocking way: this is fine because the // child has already exited and hence all the data must be already // available in the streams buffers. bufOut.ReadAll(); bufErr.ReadAll(); } #endif // wxUSE_STREAMS // Notify user about termination if required if ( !(flags & wxEXEC_SYNC) ) { if ( process ) process->OnTerminate(pid, exitcode); // in case of asynchronous execution we don't need this object any more // after the child terminates delete this; } else // sync execution { // let wxExecute() know that the process has terminated pid = 0; // Stop the event loop for synchronous wxExecute() if we're running one. if ( syncEventLoop ) syncEventLoop->ScheduleExit(); } }
/* * Perform a normal login and do a redirect if needed. Caller should perform * a normal login test. We don't throw anything but the calls we make might * and we just let them through ... */ void iSCSILibWrapper::iSCSINormalLoginWithRedirect(void) { // We don't need to remove ourselves and add ourselves back because // the methods we will call will do that. iSCSINormalLogin(); // If we were redirected, then disconnect and start again // We just perform all the correct steps if (IsRedirected()) { std::string newAddress = GetNewAddress(); iSCSIDisconnect(); SetAddress(newAddress); iSCSIConnect(); iSCSINormalLogin(); } }