summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/command_line.cc13
-rw-r--r--base/command_line.h3
-rw-r--r--base/setproctitle_linux.c3
-rw-r--r--chrome/app/chrome_dll_main.cc4
4 files changed, 9 insertions, 14 deletions
diff --git a/base/command_line.cc b/base/command_line.cc
index 84fa415..a1c2c1e 100644
--- a/base/command_line.cc
+++ b/base/command_line.cc
@@ -189,12 +189,18 @@ bool CommandLine::IsSwitch(const StringType& parameter_string,
// static
void CommandLine::Init(int argc, const char* const* argv) {
+ delete current_process_commandline_;
current_process_commandline_ = new CommandLine;
#if defined(OS_WIN)
current_process_commandline_->ParseFromString(::GetCommandLineW());
#elif defined(OS_POSIX)
current_process_commandline_->InitFromArgv(argc, argv);
#endif
+
+#if defined(OS_LINUX)
+ if (argv)
+ setproctitle_init(const_cast<char**>(argv));
+#endif
}
#if defined(OS_LINUX) || defined(OS_FREEBSD)
@@ -211,13 +217,6 @@ void CommandLine::SetProcTitle() {
}
setproctitle("%s", title.c_str());
}
-
-// static
-void CommandLine::SetTrueArgv(char** argv) {
-#if defined(OS_LINUX)
- setproctitle_init(argv);
-#endif
-}
#endif
void CommandLine::Reset() {
diff --git a/base/command_line.h b/base/command_line.h
index 6b7d1f4..4fd8e4a 100644
--- a/base/command_line.h
+++ b/base/command_line.h
@@ -66,9 +66,6 @@ class CommandLine {
// in |current_process_commandline_|. Used by the zygote host so that
// renderers show up with --type=renderer.
static void SetProcTitle();
-
- // Needed to support SetProcTitle() on Linux. Should be called by main().
- static void SetTrueArgv(char** argv);
#endif
// Destroys the current process CommandLine singleton. This is necessary if
diff --git a/base/setproctitle_linux.c b/base/setproctitle_linux.c
index 3544d3e..9924c99 100644
--- a/base/setproctitle_linux.c
+++ b/base/setproctitle_linux.c
@@ -104,6 +104,9 @@ void setproctitle(const char* fmt, ...) {
// A version of this built into glibc would not need this function, since
// it could stash the argv pointer in __libc_start_main(). But we need it.
void setproctitle_init(char** main_argv) {
+ if (g_main_argv)
+ return;
+
uintptr_t page_size = sysconf(_SC_PAGESIZE);
// Check that the argv array is in fact on the same page of memory
// as the environment array just as an added measure of protection.
diff --git a/chrome/app/chrome_dll_main.cc b/chrome/app/chrome_dll_main.cc
index 756fa96..ff9464a 100644
--- a/chrome/app/chrome_dll_main.cc
+++ b/chrome/app/chrome_dll_main.cc
@@ -344,10 +344,6 @@ int ChromeMain(int argc, char** argv) {
#else
CommandLine::Init(argc, argv);
#endif
-#if defined(OS_LINUX)
- // Set up CommandLine::SetProcTitle() support.
- CommandLine::SetTrueArgv(argv);
-#endif
const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
std::wstring process_type =