OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/common/set_process_title.h" | 5 #include "content/common/set_process_title.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_SOLARIS) | 9 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_SOLARIS) |
10 #include <limits.h> | 10 #include <limits.h> |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 title.resize(title.size() - kDeletedSuffix.size()); | 63 title.resize(title.size() - kDeletedSuffix.size()); |
64 | 64 |
65 // PR_SET_NAME is available in Linux 2.6.9 and newer. | 65 // PR_SET_NAME is available in Linux 2.6.9 and newer. |
66 // When available at run time, this sets the short process name that shows | 66 // When available at run time, this sets the short process name that shows |
67 // when the full command line is not being displayed in most process | 67 // when the full command line is not being displayed in most process |
68 // listings. | 68 // listings. |
69 prctl(PR_SET_NAME, base::FilePath(title).BaseName().value().c_str()); | 69 prctl(PR_SET_NAME, base::FilePath(title).BaseName().value().c_str()); |
70 } | 70 } |
71 #endif // defined(OS_LINUX) | 71 #endif // defined(OS_LINUX) |
72 | 72 |
73 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 73 const base::CommandLine* command_line = |
| 74 base::CommandLine::ForCurrentProcess(); |
74 for (size_t i = 1; i < command_line->argv().size(); ++i) { | 75 for (size_t i = 1; i < command_line->argv().size(); ++i) { |
75 if (!title.empty()) | 76 if (!title.empty()) |
76 title += " "; | 77 title += " "; |
77 title += command_line->argv()[i]; | 78 title += command_line->argv()[i]; |
78 } | 79 } |
79 // Disable prepending argv[0] with '-' if we prepended it ourselves above. | 80 // Disable prepending argv[0] with '-' if we prepended it ourselves above. |
80 setproctitle(have_argv0 ? "-%s" : "%s", title.c_str()); | 81 setproctitle(have_argv0 ? "-%s" : "%s", title.c_str()); |
81 } | 82 } |
82 | 83 |
83 #else | 84 #else |
84 | 85 |
85 // All other systems (basically Windows & Mac) have no need or way to implement | 86 // All other systems (basically Windows & Mac) have no need or way to implement |
86 // this function. | 87 // this function. |
87 void SetProcessTitleFromCommandLine(const char** /* main_argv */) { | 88 void SetProcessTitleFromCommandLine(const char** /* main_argv */) { |
88 } | 89 } |
89 | 90 |
90 #endif | 91 #endif |
91 | 92 |
92 } // namespace content | 93 } // namespace content |
OLD | NEW |