diff --git a/ipc/glue/GeckoChildProcessHost.cpp b/ipc/glue/GeckoChildProcessHost.cpp index 7442c566bd48..a273d05d4882 100644 --- a/ipc/glue/GeckoChildProcessHost.cpp +++ b/ipc/glue/GeckoChildProcessHost.cpp @@ -70,12 +70,20 @@ #endif #ifdef ANDROID +#include #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 { @@ -406,7 +414,22 @@ GeckoChildProcessHost::PerformAsyncLaunch(std::vector 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(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