Author: mvidner Date: Mon Jun 1 16:21:44 2009 New Revision: 57388 URL: http://svn.opensuse.org/viewcvs/yast?rev=57388&view=rev Log: Refactored a piece of Linear Programming. Yuck! Modified: trunk/core/liby2/src/Y2ProgramComponent.cc Modified: trunk/core/liby2/src/Y2ProgramComponent.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/liby2/src/Y2ProgramComponent... ============================================================================== --- trunk/core/liby2/src/Y2ProgramComponent.cc (original) +++ trunk/core/liby2/src/Y2ProgramComponent.cc Mon Jun 1 16:21:44 2009 @@ -385,39 +385,7 @@ void Y2ProgramComponent::sendToExternal(const YCPValue& value) { - if (!externalProgramOK()) - { - y2error ("External program %s died unexpectedly", bin_file.c_str()); - } - - char *v = NULL; - - if (is_non_y2) v = strdup((value->toString()).c_str()); // no brackets - else v = strdup(("(" + value->toString() + ")").c_str()); - - bool error = (write(to_external[1], v, strlen(v)) < 0); - if (error) - { - y2debug ("Error writing to external program %s: Couldn't send %s (%s)", bin_file.c_str(), v, strerror (errno)); - terminateExternalProgram(); - } - free(v); - - // We send an additional linefeed. This makes it more conveniant for non - // Y2 programs, for example that shell can do a read to get one value. For - // Y2 programs it increases the readability if you want to dump and debug - // the whole stream. - - // We MUST NOT trigger an error, if the sending of the linefeed is not - // successful. This sporadically happens after we send a module the last - // return just before the module has done its work and terminates. It then - // justs sends the result(..) message, and closes down without reading the - // linefeed. The pipe breaks down and the sending fails. But as long as we - // don't collect the process by calling wait4, we can still read the - // result (..) from the input pipe, which is very important. Otherwise the - // result value would be dropped. - - write(to_external[1], "\n", 1); + sendToExternal(value->toString()); } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org