Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(788)

Unified Diff: base/command_line.cc

Issue 196009: Linux: set the process title (that shows in "ps" etc.) of renderers correctly when using the zygote. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/command_line.h ('k') | base/setproctitle_linux.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/command_line.cc
===================================================================
--- base/command_line.cc (revision 25770)
+++ base/command_line.cc (working copy)
@@ -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 @@
#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_;
« no previous file with comments | « base/command_line.h ('k') | base/setproctitle_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698