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

Side by Side Diff: content/common/set_process_title_linux.cc

Issue 7857019: Basic scaffolding for a "content shell", i.e. test browser over the content module. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/common/set_process_title_linux.h ('k') | content/content.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 // This file implements BSD-style setproctitle() for Linux. 5 // This file implements BSD-style setproctitle() for Linux.
6 // It is written such that it can easily be compiled outside Chromium. 6 // It is written such that it can easily be compiled outside Chromium.
7 // 7 //
8 // The Linux kernel sets up two locations in memory to pass arguments and 8 // The Linux kernel sets up two locations in memory to pass arguments and
9 // environment variables to processes. First, there are two char* arrays stored 9 // environment variables to processes. First, there are two char* arrays stored
10 // one after another: argv and environ. A pointer to argv is passed to main(), 10 // one after another: argv and environ. A pointer to argv is passed to main(),
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 size_t size = snprintf(g_main_argv[0], avail_size, "%s ", g_orig_argv0); 96 size_t size = snprintf(g_main_argv[0], avail_size, "%s ", g_orig_argv0);
97 if (size < avail_size) 97 if (size < avail_size)
98 vsnprintf(g_main_argv[0] + size, avail_size - size, fmt, ap); 98 vsnprintf(g_main_argv[0] + size, avail_size - size, fmt, ap);
99 } 99 }
100 va_end(ap); 100 va_end(ap);
101 g_main_argv[1] = NULL; 101 g_main_argv[1] = NULL;
102 } 102 }
103 103
104 // A version of this built into glibc would not need this function, since 104 // A version of this built into glibc would not need this function, since
105 // it could stash the argv pointer in __libc_start_main(). But we need it. 105 // it could stash the argv pointer in __libc_start_main(). But we need it.
106 void setproctitle_init(char** main_argv) { 106 void setproctitle_init(const char** main_argv) {
107 if (g_main_argv) 107 if (g_main_argv)
108 return; 108 return;
109 109
110 uintptr_t page_size = sysconf(_SC_PAGESIZE); 110 uintptr_t page_size = sysconf(_SC_PAGESIZE);
111 // Check that the argv array is in fact on the same page of memory 111 // Check that the argv array is in fact on the same page of memory
112 // as the environment array just as an added measure of protection. 112 // as the environment array just as an added measure of protection.
113 if (((uintptr_t) environ) / page_size == ((uintptr_t) main_argv) / page_size) 113 if (((uintptr_t) environ) / page_size == ((uintptr_t) main_argv) / page_size)
114 g_main_argv = main_argv; 114 g_main_argv = const_cast<char**>(main_argv);
115 } 115 }
OLDNEW
« no previous file with comments | « content/common/set_process_title_linux.h ('k') | content/content.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698