Bug 606074: ensure that we share the Android system properties memory-map with the child process, r=cjones, a=blocking-fennec:2.0:mfinkle

This commit is contained in:
Brian Crowder 2011-01-20 09:01:31 -08:00
parent 085217d130
commit 9dd1b4486c

View File

@ -70,12 +70,20 @@
#endif
#ifdef ANDROID
#include <sys/system_properties.h>
#include "APKOpen.h"
#endif
using mozilla::MonitorAutoEnter;
using mozilla::ipc::GeckoChildProcessHost;
#ifdef ANDROID
// Like its predecessor in nsExceptionHandler.cpp, this is
// the magic number of a file descriptor remapping we must
// preserve for the child process.
static const int kMagicAndroidSystemPropFd = 5;
#endif
template<>
struct RunnableMethodTraits<GeckoChildProcessHost>
{
@ -406,7 +414,22 @@ GeckoChildProcessHost::PerformAsyncLaunch(std::vector<std::string> aExtraOpts, b
// fill the last arg with something if there's no cache
if (cacheStr.IsEmpty())
cacheStr.AppendLiteral("-");
#endif
// Remap the Android property workspace to a well-known int,
// and update the environment to reflect the new value for the
// child process.
const char *apws = getenv("ANDROID_PROPERTY_WORKSPACE");
if (apws) {
int fd = atoi(apws);
mFileMap.push_back(std::pair<int, int>(fd, kMagicAndroidSystemPropFd));
char buf[32];
char *szptr = strchr(apws, ',');
snprintf(buf, sizeof(buf), "%d%s", kMagicAndroidSystemPropFd, szptr);
newEnvVars["ANDROID_PROPERTY_WORKSPACE"] = buf;
}
#endif // ANDROID
// remap the IPC socket fd to a well-known int, as the OS does for
// STDOUT_FILENO, for example