diff options
author | mdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-10 18:02:17 +0000 |
---|---|---|
committer | mdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-10 18:02:17 +0000 |
commit | 7f113f39afed41b39d5c937039879c5d822c6b5e (patch) | |
tree | db014b39bf9cdc6daf6aae947a16c4c5ff5d1721 /base/command_line.cc | |
parent | e4e3caed74ecfe1ef1da4c7ba8fc076f59a53ef1 (diff) | |
download | chromium_src-7f113f39afed41b39d5c937039879c5d822c6b5e.zip chromium_src-7f113f39afed41b39d5c937039879c5d822c6b5e.tar.gz chromium_src-7f113f39afed41b39d5c937039879c5d822c6b5e.tar.bz2 |
Linux: set the process title (that shows in "ps" etc.) of renderers correctly when using the zygote.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/196009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25877 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/command_line.cc')
-rw-r--r-- | base/command_line.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/base/command_line.cc b/base/command_line.cc index 43b068c..04c1ece 100644 --- a/base/command_line.cc +++ b/base/command_line.cc @@ -7,6 +7,9 @@ #if defined(OS_WIN) #include <windows.h> #include <shellapi.h> +#elif defined(OS_FREEBSD) +#include <stdlib.h> +#include <unistd.h> #endif #include <algorithm> @@ -17,6 +20,11 @@ #include "base/string_util.h" #include "base/sys_string_conversions.h" +#if defined(OS_LINUX) +// Linux/glibc doesn't natively have setproctitle(). +#include "base/setproctitle_linux.h" +#endif + CommandLine* CommandLine::current_process_commandline_ = NULL; // Since we use a lazy match, make sure that longer versions (like L"--") @@ -194,6 +202,29 @@ void CommandLine::Init(const std::vector<std::string>& argv) { #endif } +#if defined(OS_LINUX) || defined(OS_FREEBSD) +// static +void CommandLine::SetProcTitle() { + // Build a single string which consists of all the arguments separated + // by spaces. We can't actually keep them separate due to the way the + // setproctitle() function works. + std::string title; + for (size_t i = 1; i < current_process_commandline_->argv_.size(); ++i) { + if (!title.empty()) + title += " "; + title += current_process_commandline_->argv_[i]; + } + setproctitle("%s", title.c_str()); +} + +// static +void CommandLine::SetTrueArgv(char** argv) { +#if defined(OS_LINUX) + setproctitle_init(argv); +#endif +} +#endif + void CommandLine::Terminate() { DCHECK(current_process_commandline_ != NULL); delete current_process_commandline_; |