Author: kmachalkova
Date: Fri Aug 24 14:44:13 2007
New Revision: 40457
URL: http://svn.opensuse.org/viewcvs/yast?rev=40457&view=rev
Log:
- Redirecting stdout/stderr to log is now separate function
Modified:
trunk/ncurses/src/NCurses.cc
trunk/ncurses/src/NCurses.h
trunk/ncurses/src/YNCursesUI.cc
Modified: trunk/ncurses/src/NCurses.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses/src/NCurses.cc?rev=40457&r1=40456&r2=40457&view=diff
==============================================================================
--- trunk/ncurses/src/NCurses.cc (original)
+++ trunk/ncurses/src/NCurses.cc Fri Aug 24 14:44:13 2007
@@ -209,8 +209,6 @@
if ( title_line() && ::ripoffline( 1, ripinit ) != OK )
throw NCursesError( "ripoffline() failed" );
-
- string log = get_log_filename();
UIMIL << "isatty(stdin)" << (isatty(0) ? "yes" : "no") << endl;
if (isatty( 0 )) {
@@ -256,21 +254,15 @@
}
}
}
+
+ //FIXME: Enable these with multithread support
+ //duplicate stdout and stderr before redirecting them to log
+ //so that they can be regenerated before system() call
+ //stdout_save = dup(1);
+ //stderr_save = dup(2);
- UIMIL << "isatty(stderr)" << (isatty(2) ? "yes" : "no") << endl;
- if (isatty(2) && theTerm) {
- // redirect stderr to log
- close(2);
- open(log.c_str(), O_APPEND | O_CREAT);
- }
-
- UIMIL << "isatty(stdout)" << (isatty(1) ? "yes" : "no") << endl;
- if (isatty(1) && theTerm) {
- // redirect stdout to log
- close(1);
- open(log.c_str(), O_APPEND | O_CREAT);
- }
-
+ RedirectToLog();
+
if ( !theTerm ) {
UIMIL << "no term so fall back to initscr" << endl;
if ( ::initscr() == NULL )
@@ -574,6 +566,31 @@
///////////////////////////////////////////////////////////////////
//
//
+// METHOD NAME : NCurses::RedirectToLog
+// METHOD TYPE : void
+//
+void NCurses::RedirectToLog()
+{
+ string log = get_log_filename();
+
+ UIMIL << "isatty(stderr)" << (isatty(2) ? "yes" : "no") << endl;
+ if (isatty(2) && theTerm) {
+ // redirect stderr to log
+ close(2);
+ open(log.c_str(), O_APPEND | O_CREAT);
+ }
+
+ UIMIL << "isatty(stdout)" << (isatty(1) ? "yes" : "no") << endl;
+ if (isatty(1) && theTerm) {
+ // redirect stdout to log
+ close(1);
+ open(log.c_str(), O_APPEND | O_CREAT);
+ }
+
+}
+///////////////////////////////////////////////////////////////////
+//
+//
// METHOD NAME : NCurses::ResizeEvent
// METHOD TYPE : void
//
Modified: trunk/ncurses/src/NCurses.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses/src/NCurses.h?rev=40457&r1=40456&r2=40457&view=diff
==============================================================================
--- trunk/ncurses/src/NCurses.h (original)
+++ trunk/ncurses/src/NCurses.h Fri Aug 24 14:44:13 2007
@@ -173,6 +173,10 @@
NCurses();
virtual ~NCurses();
+ //FIXME: Enable these with multithread support
+ //int stdout_save;
+ //int stderr_save;
+
static int cols() { return ::COLS; }
static int lines() { return ::LINES; }
@@ -194,6 +198,7 @@
// actually not for public use
static void ForgetDlg( NCDialog * dlg_r );
static void RememberDlg( NCDialog * dlg_r );
+ void RedirectToLog();
static void ResizeEvent();
private:
static set