]> khamidou — GitHub mirrors - electron.git/commitdiff
Make process.argv work with zygote
authorCheng Zhao <zcbenz@gmail.com>
Fri, 19 Jun 2015 14:56:10 +0000 (22:56 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Fri, 19 Jun 2015 14:56:10 +0000 (22:56 +0800)
atom/app/atom_main_args.cc
atom/app/atom_main_args.h
atom/common/node_bindings.cc

index b9ef7c43a34b866ea9d2a9d81a9fcf0d91112e69..ac1c96c1bcaf659e1b819d8752192ba32f860a17 100644 (file)
@@ -3,7 +3,9 @@
 // found in the LICENSE file.
 
 #include "atom/app/atom_main_args.h"
-#include "vendor/node/deps/uv/include/uv.h"
+
+#include "base/command_line.h"
+#include "node/deps/uv/include/uv.h"
 
 namespace atom {
 
@@ -19,4 +21,11 @@ void AtomCommandLine::Init(int argc, const char* const* argv) {
   }
 }
 
+#if defined(OS_LINUX)
+// static
+void AtomCommandLine::InitializeFromCommandLine() {
+  argv_ = base::CommandLine::ForCurrentProcess()->argv();
+}
+#endif
+
 }  // namespace atom
index c3bc0a9823dc67dc93e02a176a2e17a1d34acbd5..5dd42713c65a514b50409713e581f972aa4571d3 100644 (file)
@@ -8,7 +8,7 @@
 #include <string>
 #include <vector>
 
-#include "base/macros.h"
+#include "base/basictypes.h"
 
 namespace atom {
 
@@ -18,6 +18,12 @@ class AtomCommandLine {
   static void Init(int argc, const char* const* argv);
   static std::vector<std::string> argv() { return argv_; }
 
+#if defined(OS_LINUX)
+  // On Linux the command line has to be read from base::CommandLine since
+  // it is using zygote.
+  static void InitializeFromCommandLine();
+#endif
+
  private:
   static std::vector<std::string> argv_;
 
index eb627d06b7575e985dd592f71a1aad54f20eb634..ff1d646c4d349a15fc53995feaf2691621c5bc76 100644 (file)
@@ -128,6 +128,12 @@ void NodeBindings::Initialize() {
   node::g_standalone_mode = is_browser_;
   node::g_upstream_node_mode = false;
 
+#if defined(OS_LINUX)
+  // Get real command line in renderer process forked by zygote.
+  if (!is_browser_)
+    AtomCommandLine::InitializeFromCommandLine();
+#endif
+
   // Parse the debug args.
   auto args = AtomCommandLine::argv();
   for (const std::string& arg : args)