summaryrefslogtreecommitdiffstats
path: root/base/command_line.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-29 21:06:43 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-29 21:06:43 +0000
commit74e9fa2c35b2fa8d293ad5369cc9cb6e9bbad2a1 (patch)
tree5a97c84fd8c1daee2e97e569ef9c8b43cf1a97f5 /base/command_line.cc
parentda827048d636a9c8cc5b0217077c2fe97cd6b8fe (diff)
downloadchromium_src-74e9fa2c35b2fa8d293ad5369cc9cb6e9bbad2a1.zip
chromium_src-74e9fa2c35b2fa8d293ad5369cc9cb6e9bbad2a1.tar.gz
chromium_src-74e9fa2c35b2fa8d293ad5369cc9cb6e9bbad2a1.tar.bz2
Move the SetProcTitle code out of base and into chrome/common. This is only
used to support the weird way Chrome manages processes, so doesn't belong in the central CommandLine class. This also provides an empty implementation on Mac & Windows to avoid some ifdefs in the main functions. TEST=everything compiles BUG=none Review URL: http://codereview.chromium.org/6002013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70276 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/command_line.cc')
-rw-r--r--base/command_line.cc70
1 files changed, 8 insertions, 62 deletions
diff --git a/base/command_line.cc b/base/command_line.cc
index 70d6872..66b4437 100644
--- a/base/command_line.cc
+++ b/base/command_line.cc
@@ -4,18 +4,6 @@
#include "base/command_line.h"
-#if defined(OS_WIN)
-#include <windows.h>
-#include <shellapi.h>
-#elif defined(OS_POSIX)
-#include <limits.h>
-#include <stdlib.h>
-#include <unistd.h>
-#endif
-#if defined(OS_LINUX)
-#include <sys/prctl.h>
-#endif
-
#include <algorithm>
#include "base/file_path.h"
@@ -26,10 +14,15 @@
#include "base/string_util.h"
#include "base/sys_string_conversions.h"
#include "base/utf_string_conversions.h"
+#include "build/build_config.h"
-#if defined(OS_LINUX)
-// Linux/glibc doesn't natively have setproctitle().
-#include "base/setproctitle_linux.h"
+#if defined(OS_WIN)
+#include <windows.h>
+#include <shellapi.h>
+#elif defined(OS_POSIX)
+#include <limits.h>
+#include <stdlib.h>
+#include <unistd.h>
#endif
CommandLine* CommandLine::current_process_commandline_ = NULL;
@@ -218,55 +211,8 @@ void CommandLine::Init(int argc, const char* const* argv) {
#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_POSIX) && !defined(OS_MACOSX) && !defined(OS_NACL)
-// 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;
- bool have_argv0 = false;
-#if defined(OS_LINUX)
- // In Linux we sometimes exec ourselves from /proc/self/exe, but this makes us
- // show up as "exe" in process listings. Read the symlink /proc/self/exe and
- // use the path it points at for our process title. Note that this is only for
- // display purposes and has no TOCTTOU security implications.
- FilePath target;
- FilePath self_exe("/proc/self/exe");
- if (file_util::ReadSymbolicLink(self_exe, &target)) {
- have_argv0 = true;
- title = target.value();
- // If the binary has since been deleted, Linux appends " (deleted)" to the
- // symlink target. Remove it, since this is not really part of our name.
- const std::string kDeletedSuffix = " (deleted)";
- if (EndsWith(title, kDeletedSuffix, true))
- title.resize(title.size() - kDeletedSuffix.size());
-#if defined(PR_SET_NAME)
- // If PR_SET_NAME is available at compile time, we try using it. We ignore
- // any errors if the kernel does not support it at runtime though. When
- // available, this lets us set the short process name that shows when the
- // full command line is not being displayed in most process listings.
- prctl(PR_SET_NAME, FilePath(title).BaseName().value().c_str());
-#endif
- }
-#endif
- for (size_t i = 1; i < current_process_commandline_->argv_.size(); ++i) {
- if (!title.empty())
- title += " ";
- title += current_process_commandline_->argv_[i];
- }
- // Disable prepending argv[0] with '-' if we prepended it ourselves above.
- setproctitle(have_argv0 ? "-%s" : "%s", title.c_str());
-}
-#endif
-
void CommandLine::Reset() {
DCHECK(current_process_commandline_ != NULL);
delete current_process_commandline_;