-
By the way, if you'd tried using noskipws you should have found it worked. That's because Pstreams behaves the same as the standard streams.
2009-09-25 23:03:59 UTC by redi
-
Try replacing get_command_result with this:
void get_command_result(std::string const command, std::string& info)
{
std::string input;
std::istringstream query("a\nb\nc\n");
while (query >> input)
{
info += input;
}
}
Notice that there are newlines in the string. Notice that the output does not contain newlines.
That's how iostreams work, please read about...
2009-09-25 22:44:39 UTC by redi
-
void get_command_result(std::string const command, std::string& info)
{
std::string input;
redi::ipstream query(command);
while (query >> input)
{
info += input;
}
}
int main(void)
{
try
{
std::string info;
get_command_result("cd /home/elfring/Projekte/PStreams/trunk && find . -name '*.cc'", info);
if (info.empty())
{...
2009-09-25 14:17:04 UTC by elfring
-
Pstreams doesn't do any translation or anything else with the bytes transferred between processes, you can check the code to verify this yourself. If characters are being lost it is by the shell command you are running or by your own code.
Please provide a minimal testcase demonstrating the problem if you still think pstreams is responsible for this behaviour.
2009-09-25 12:16:53 UTC by redi
-
I have instructed an ipstream object to execute a find command. The result is returned in a single line while I expect that each found file name will appear on a separate line.
I guess that the newline/end-of-line character gets lost or suppressed somewhere. I would appreciate if all whitespace characters can be kept.
A similar behaviour can be adjusted by the function "noskipws" for...
2009-09-25 11:33:52 UTC by elfring
-
If execvp fails the process will call _exit(errno) ... what more do you want? Where would abort be helpful?
Calling exit(errno) would be incorrect as it would run destructors in the child process for objects that were created in the parent.
If you have any useful suggestions please propose patches and I will consider them, until then I'm closing this as invalid.
2009-09-23 21:46:26 UTC by redi
-
If you would like to exclude C++ exceptions to handle exceptional situations, I imagine that the reactions "exit(errno)" or "abort()" should be considered for the completion of error handling.
I suggest to avoid unchecked function calls. Would you like to detect every error situation as early as possible?.
2009-09-23 19:29:47 UTC by elfring
-
> I have just performed my own little code review.
So do you agree it's pointless to check the return value of execvp(3)? It will return -1 or it will not return, so checking it is stupid. What do you suggest I do if write(2) fails, when I am about to close the descriptors and exit anyway? If you want to be really strict you should check the result of close(2) as well, but again, there's...
2009-09-23 18:03:09 UTC by redi
-
I do not like your suggestion to ignore the return value by casting it to void. I did not get warnings by a static source code analysis tool. I have just performed my own little code review.
Would you like to reduce the efforts for error code checking by an exception class hierarchy?.
2009-09-23 17:49:17 UTC by elfring
-
redi committed patchset 310 of module pstreams to the PStreams CVS repository, changing 1 files.
2009-09-23 15:53:09 UTC by redi