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 24 matching lines...) Expand all Loading... | |
35 !defined(OS_ANDROID) | 35 !defined(OS_ANDROID) |
36 | 36 |
37 void SetProcessTitleFromCommandLine(const char** main_argv) { | 37 void SetProcessTitleFromCommandLine(const char** main_argv) { |
38 // Build a single string which consists of all the arguments separated | 38 // Build a single string which consists of all the arguments separated |
39 // by spaces. We can't actually keep them separate due to the way the | 39 // by spaces. We can't actually keep them separate due to the way the |
40 // setproctitle() function works. | 40 // setproctitle() function works. |
41 std::string title; | 41 std::string title; |
42 bool have_argv0 = false; | 42 bool have_argv0 = false; |
43 | 43 |
44 #if defined(OS_LINUX) | 44 #if defined(OS_LINUX) |
45 DCHECK_EQ(base::PlatformThread::CurrentId(), getpid()); | |
piman
2014/05/20 05:09:22
nit: maybe DCHECK_EQ(gettid(), getpid()); ?
I thi
| |
46 | |
47 if (main_argv) | 45 if (main_argv) |
48 setproctitle_init(main_argv); | 46 setproctitle_init(main_argv); |
49 | 47 |
50 // In Linux we sometimes exec ourselves from /proc/self/exe, but this makes us | 48 // In Linux we sometimes exec ourselves from /proc/self/exe, but this makes us |
51 // show up as "exe" in process listings. Read the symlink /proc/self/exe and | 49 // show up as "exe" in process listings. Read the symlink /proc/self/exe and |
52 // use the path it points at for our process title. Note that this is only for | 50 // use the path it points at for our process title. Note that this is only for |
53 // display purposes and has no TOCTTOU security implications. | 51 // display purposes and has no TOCTTOU security implications. |
54 base::FilePath target; | 52 base::FilePath target; |
55 base::FilePath self_exe(base::kProcSelfExe); | 53 base::FilePath self_exe(base::kProcSelfExe); |
56 if (base::ReadSymbolicLink(self_exe, &target)) { | 54 if (base::ReadSymbolicLink(self_exe, &target)) { |
(...skipping 26 matching lines...) Expand all Loading... | |
83 #else | 81 #else |
84 | 82 |
85 // All other systems (basically Windows & Mac) have no need or way to implement | 83 // All other systems (basically Windows & Mac) have no need or way to implement |
86 // this function. | 84 // this function. |
87 void SetProcessTitleFromCommandLine(const char** /* main_argv */) { | 85 void SetProcessTitleFromCommandLine(const char** /* main_argv */) { |
88 } | 86 } |
89 | 87 |
90 #endif | 88 #endif |
91 | 89 |
92 } // namespace content | 90 } // namespace content |
OLD | NEW |