Author: mvidner Date: Wed Feb 25 14:50:23 2009 New Revision: 55744 URL: http://svn.opensuse.org/viewcvs/yast?rev=55744&view=rev Log: Fixed tty_wrapper losing output: stdio was interrupted by SIGCHLD (bnc#470645). Modified: trunk/core/base/tools/tty_wrapper/tty_wrapper.cc trunk/core/package/yast2-core.changes Modified: trunk/core/base/tools/tty_wrapper/tty_wrapper.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/base/tools/tty_wrapper/tty_wrapper.cc?rev=55744&r1=55743&r2=55744&view=diff ============================================================================== --- trunk/core/base/tools/tty_wrapper/tty_wrapper.cc (original) +++ trunk/core/base/tools/tty_wrapper/tty_wrapper.cc Wed Feb 25 14:50:23 2009 @@ -74,6 +74,32 @@ return true; } +void output(const std::string & s, int fd) +{ + const char *cs = s.c_str(); + while (true) { + ssize_t n = s.size(); + ssize_t w = write(fd, cs, n); + if (w == n) + break; // success + else if (w == -1) { + if (errno == EINTR) { + // perror("gotcha"); // bnc#470645 + } + else { + perror("write"); // other cases + break; + } + } + else { + errno = 0; + perror("short"); + cs += w; + n -= w; + } + } +} + int main(int argc, char **argv) { if (argc > 1) @@ -168,7 +194,7 @@ { // read stdout of the subprocess and print it on stdout std::string std_out(subprocess.read()); - std::cout << std_out; + output(std_out, 1); } // stderr available @@ -176,7 +202,7 @@ { // read stderr of the subprocess and print it on stderr std::string err_out(subprocess.readErr()); - std::cerr << err_out; + output(err_out, 2); } } } @@ -189,4 +215,3 @@ return 1; } } - Modified: trunk/core/package/yast2-core.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/package/yast2-core.changes?rev=55744&r1=55743&r2=55744&view=diff ============================================================================== --- trunk/core/package/yast2-core.changes (original) +++ trunk/core/package/yast2-core.changes Wed Feb 25 14:50:23 2009 @@ -1,4 +1,9 @@ ------------------------------------------------------------------- +Wed Feb 25 14:49:33 CET 2009 - mvidner@suse.cz + +- Fixed tty_wrapper losing output: stdio was interrupted by SIGCHLD (bnc#470645). + +------------------------------------------------------------------- Thu Jan 29 15:15:57 CET 2009 - aschnell@suse.de - added dbus client agent (required for bnc #464453) -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org