Index: subprocess.cc |
diff --git a/subprocess.cc b/subprocess.cc |
index 99605ddc1ddf0dc8a120d1b9c00a71941c409c5b..8671584d637de3e177d9d59560d978c6f0df0e39 100755 |
--- a/subprocess.cc |
+++ b/subprocess.cc |
@@ -6,6 +6,7 @@ |
#include <stdlib.h> |
#include <string.h> |
#include <string> |
+#include <unistd.h> |
#include <vector> |
#include "base/logging.h" |
#include "base/scoped_ptr.h" |
@@ -28,6 +29,10 @@ void Subprocess::GChildExitedCallback(GPid pid, gint status, gpointer data) { |
delete tag; |
} |
+void Subprocess::GRedirectStderrToStdout(gpointer user_data) { |
+ dup2(1, 2); |
+} |
+ |
namespace { |
void FreeArgv(char** argv) { |
for (int i = 0; argv[i]; i++) { |
@@ -124,25 +129,22 @@ bool Subprocess::SynchronousExec(const std::vector<std::string>& cmd, |
ScopedFreeArgPointer argp_free(argp); |
char* child_stdout; |
- char* child_stderr; |
bool success = g_spawn_sync(NULL, // working directory |
argv.get(), |
argp, |
- static_cast<GSpawnFlags>(NULL), // flags |
- NULL, // child setup function |
+ G_SPAWN_STDERR_TO_DEV_NULL, // flags |
+ GRedirectStderrToStdout, // child setup function |
NULL, // data for child setup function |
&child_stdout, |
- &child_stderr, |
+ NULL, |
return_code, |
&err); |
FreeArgv(argv.get()); |
if (err) |
LOG(INFO) << "err is: " << err->code << ", " << err->message; |
if (child_stdout && strlen(child_stdout)) |
- LOG(INFO) << "Subprocess stdout:" << child_stdout; |
- if (child_stderr && strlen(child_stderr)) |
- LOG(INFO) << "Subprocess stderr:" << child_stderr; |
+ LOG(INFO) << "Subprocess output:\n" << child_stdout; |
Kenneth Waters
2010/09/17 20:08:28
Do we need to call "g_free(child_stdout)" here ?
adlr
2010/09/17 20:16:27
ask valgrind?
|
return success; |
} |