Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(528)

Unified Diff: subprocess.cc

Issue 3398011: AU: Mix stdout and stderr together in the logs. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « subprocess.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « subprocess.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698