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

Side by Side Diff: services/service_manager/embedder/set_process_title.cc

Issue 2613653003: Move some basic early process init into Service Manager (Closed)
Patch Set: fix mac shutdown order Created 3 years, 9 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 unified diff | Download patch
OLDNEW
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 "services/service_manager/embedder/set_process_title.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 10
11 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_SOLARIS) 11 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_SOLARIS)
12 #include <limits.h> 12 #include <limits.h>
13 #include <stdlib.h> 13 #include <stdlib.h>
14 #include <unistd.h> 14 #include <unistd.h>
15 15
16 #include <string> 16 #include <string>
17 17
18 #include "base/command_line.h" 18 #include "base/command_line.h"
19 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_SOLARIS) 19 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_SOLARIS)
20 20
21 #if defined(OS_LINUX) 21 #if defined(OS_LINUX)
22 #include <sys/prctl.h> 22 #include <sys/prctl.h>
23 23
24 #include "base/files/file_path.h" 24 #include "base/files/file_path.h"
25 #include "base/files/file_util.h" 25 #include "base/files/file_util.h"
26 #include "base/process/process_metrics.h" 26 #include "base/process/process_metrics.h"
27 #include "base/strings/string_util.h" 27 #include "base/strings/string_util.h"
28 #include "base/threading/platform_thread.h" 28 #include "base/threading/platform_thread.h"
29 // Linux/glibc doesn't natively have setproctitle(). 29 // Linux/glibc doesn't natively have setproctitle().
30 #include "content/common/set_process_title_linux.h" 30 #include "services/service_manager/embedder/set_process_title_linux.h"
31 #endif // defined(OS_LINUX) 31 #endif // defined(OS_LINUX)
32 32
33 namespace content { 33 namespace service_manager {
34 34
35 // TODO(jrg): Find out if setproctitle or equivalent is available on Android. 35 // TODO(jrg): Find out if setproctitle or equivalent is available on Android.
36 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_SOLARIS) && \ 36 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_SOLARIS) && \
37 !defined(OS_ANDROID) 37 !defined(OS_ANDROID)
38 38
39 void SetProcessTitleFromCommandLine(const char** main_argv) { 39 void SetProcessTitleFromCommandLine(const char** main_argv) {
40 // Build a single string which consists of all the arguments separated 40 // Build a single string which consists of all the arguments separated
41 // by spaces. We can't actually keep them separate due to the way the 41 // by spaces. We can't actually keep them separate due to the way the
42 // setproctitle() function works. 42 // setproctitle() function works.
43 std::string title; 43 std::string title;
44 bool have_argv0 = false; 44 bool have_argv0 = false;
45 45
46 #if defined(OS_LINUX) 46 #if defined(OS_LINUX)
47 DCHECK_EQ(base::PlatformThread::CurrentId(), getpid()); 47 DCHECK_EQ(base::PlatformThread::CurrentId(), getpid());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 title += command_line->argv()[i]; 80 title += command_line->argv()[i];
81 } 81 }
82 // Disable prepending argv[0] with '-' if we prepended it ourselves above. 82 // Disable prepending argv[0] with '-' if we prepended it ourselves above.
83 setproctitle(have_argv0 ? "-%s" : "%s", title.c_str()); 83 setproctitle(have_argv0 ? "-%s" : "%s", title.c_str());
84 } 84 }
85 85
86 #else 86 #else
87 87
88 // All other systems (basically Windows & Mac) have no need or way to implement 88 // All other systems (basically Windows & Mac) have no need or way to implement
89 // this function. 89 // this function.
90 void SetProcessTitleFromCommandLine(const char** /* main_argv */) { 90 void SetProcessTitleFromCommandLine(const char** /* main_argv */) {}
91 }
92 91
93 #endif 92 #endif
94 93
95 } // namespace content 94 } // namespace service_manager
OLDNEW
« no previous file with comments | « services/service_manager/embedder/set_process_title.h ('k') | services/service_manager/embedder/set_process_title_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698