update engine: 32- and 64-bit compile
Review URL: http://codereview.chromium.org/1599029
diff --git a/subprocess.cc b/subprocess.cc
index 89b6cad..3a6597e 100644
--- a/subprocess.cc
+++ b/subprocess.cc
@@ -9,6 +9,7 @@
#include <vector>
#include "chromeos/obsolete_logging.h"
#include "base/scoped_ptr.h"
+#include "base/string_util.h"
using std::string;
using std::vector;
@@ -18,7 +19,7 @@
void Subprocess::GChildExitedCallback(GPid pid, gint status, gpointer data) {
COMPILE_ASSERT(sizeof(guint) == sizeof(uint32),
guint_uint32_size_mismatch);
- guint *tag = reinterpret_cast<guint*>(data);
+ guint* tag = reinterpret_cast<guint*>(data);
const SubprocessCallbackRecord& record = Get().callback_records_[*tag];
if (record.callback)
record.callback(status, record.callback_data);
@@ -38,16 +39,22 @@
uint32 Subprocess::Exec(const std::vector<std::string>& cmd,
ExecCallback callback,
- void *p) {
+ void* p) {
GPid child_pid;
- GError *err;
- scoped_array<char *> argv(new char*[cmd.size() + 1]);
+ GError* err;
+ scoped_array<char*> argv(new char*[cmd.size() + 1]);
for (unsigned int i = 0; i < cmd.size(); i++) {
argv[i] = strdup(cmd[i].c_str());
}
argv[cmd.size()] = NULL;
- char *argp[1];
- argp[0] = NULL;
+
+ scoped_array<char*> argp(new char*[2]);
+ argp[0] = argp[1] = NULL;
+ const char* kLdLibraryPathKey = "LD_LIBRARY_PATH";
+ if (getenv(kLdLibraryPathKey)) {
+ argp[0] = strdup(StringPrintf("%s=%s", kLdLibraryPathKey,
+ getenv(kLdLibraryPathKey)).c_str());
+ }
SubprocessCallbackRecord callback_record;
callback_record.callback = callback;
@@ -55,7 +62,7 @@
bool success = g_spawn_async(NULL, // working directory
argv.get(),
- argp,
+ argp.get(),
G_SPAWN_DO_NOT_REAP_CHILD, // flags
NULL, // child setup function
NULL, // child setup data pointer
@@ -66,7 +73,7 @@
LOG(ERROR) << "g_spawn_async failed";
return 0;
}
- guint *tag = new guint;
+ guint* tag = new guint;
*tag = g_child_watch_add(child_pid, GChildExitedCallback, tag);
callback_records_[*tag] = callback_record;
return *tag;
@@ -80,13 +87,13 @@
bool Subprocess::SynchronousExec(const std::vector<std::string>& cmd,
int* return_code) {
- GError *err = NULL;
- scoped_array<char *> argv(new char*[cmd.size() + 1]);
+ GError* err = NULL;
+ scoped_array<char*> argv(new char*[cmd.size() + 1]);
for (unsigned int i = 0; i < cmd.size(); i++) {
argv[i] = strdup(cmd[i].c_str());
}
argv[cmd.size()] = NULL;
- char *argp[1];
+ char* argp[1];
argp[0] = NULL;
bool success = g_spawn_sync(NULL, // working directory