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

Side by Side Diff: chrome/browser/zygote_host_linux.h

Issue 5172009: This adds some plumbing for propagating the reason for a renderer's death (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Final review changes Created 10 years 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
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 #ifndef CHROME_BROWSER_ZYGOTE_HOST_LINUX_H_ 5 #ifndef CHROME_BROWSER_ZYGOTE_HOST_LINUX_H_
6 #define CHROME_BROWSER_ZYGOTE_HOST_LINUX_H_ 6 #define CHROME_BROWSER_ZYGOTE_HOST_LINUX_H_
7 #pragma once 7 #pragma once
8 8
9 #include <unistd.h> 9 #include <unistd.h>
10 10
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/global_descriptors_posix.h" 14 #include "base/global_descriptors_posix.h"
15 #include "base/lock.h" 15 #include "base/lock.h"
16 #include "base/process.h" 16 #include "base/process.h"
17 #include "base/process_util.h"
17 18
18 template<typename Type> 19 template<typename Type>
19 struct DefaultSingletonTraits; 20 struct DefaultSingletonTraits;
20 21
21 static const char kZygoteMagic[] = "ZYGOTE_OK"; 22 static const char kZygoteMagic[] = "ZYGOTE_OK";
22 23
23 // http://code.google.com/p/chromium/wiki/LinuxZygote 24 // http://code.google.com/p/chromium/wiki/LinuxZygote
24 25
25 // The zygote host is the interface, in the browser process, to the zygote 26 // The zygote host is the interface, in the browser process, to the zygote
26 // process. 27 // process.
27 class ZygoteHost { 28 class ZygoteHost {
28 public: 29 public:
29 // Returns the singleton instance. 30 // Returns the singleton instance.
30 static ZygoteHost* GetInstance(); 31 static ZygoteHost* GetInstance();
31 32
32 void Init(const std::string& sandbox_cmd); 33 void Init(const std::string& sandbox_cmd);
33 34
34 // Tries to start a renderer process. Returns its pid on success, otherwise 35 // Tries to start a renderer process. Returns its pid on success, otherwise
35 // base::kNullProcessHandle; 36 // base::kNullProcessHandle;
36 pid_t ForkRenderer(const std::vector<std::string>& command_line, 37 pid_t ForkRenderer(const std::vector<std::string>& command_line,
37 const base::GlobalDescriptors::Mapping& mapping); 38 const base::GlobalDescriptors::Mapping& mapping);
38 void EnsureProcessTerminated(pid_t process); 39 void EnsureProcessTerminated(pid_t process);
39 40
40 // Get the termination status (exit code) of the process and return true if 41 // Get the termination status (and, optionally, the exit code) of
41 // the status indicates the process crashed. |child_exited| is set to true 42 // the process. |exit_code| is set to the exit code of the child
42 // iff the child process has terminated. (|child_exited| may be NULL.) 43 // process. (|exit_code| may be NULL.)
43 bool DidProcessCrash(base::ProcessHandle handle, bool* child_exited); 44 base::TerminationStatus GetTerminationStatus(base::ProcessHandle handle,
45 int* exit_code);
44 46
45 // These are the command codes used on the wire between the browser and the 47 // These are the command codes used on the wire between the browser and the
46 // zygote. 48 // zygote.
47 enum { 49 enum {
48 kCmdFork = 0, // Fork off a new renderer. 50 kCmdFork = 0, // Fork off a new renderer.
49 kCmdReap = 1, // Reap a renderer child. 51 kCmdReap = 1, // Reap a renderer child.
50 kCmdDidProcessCrash = 2, // Check if child process crashed. 52 kCmdGetTerminationStatus = 2, // Check what happend to a child process.
51 kCmdGetSandboxStatus = 3, // Read a bitmask of kSandbox* 53 kCmdGetSandboxStatus = 3, // Read a bitmask of kSandbox*
52 }; 54 };
53 55
54 // These form a bitmask which describes the conditions of the sandbox that 56 // These form a bitmask which describes the conditions of the sandbox that
55 // the zygote finds itself in. 57 // the zygote finds itself in.
56 enum { 58 enum {
57 kSandboxSUID = 1 << 0, // SUID sandbox active 59 kSandboxSUID = 1 << 0, // SUID sandbox active
58 kSandboxPIDNS = 1 << 1, // SUID sandbox is using the PID namespace 60 kSandboxPIDNS = 1 << 1, // SUID sandbox is using the PID namespace
59 kSandboxNetNS = 1 << 2, // SUID sandbox is using the network namespace 61 kSandboxNetNS = 1 << 2, // SUID sandbox is using the network namespace
60 kSandboxSeccomp = 1 << 3, // seccomp sandbox active. 62 kSandboxSeccomp = 1 << 3, // seccomp sandbox active.
61 }; 63 };
62 64
63 pid_t pid() const { return pid_; } 65 pid_t pid() const { return pid_; }
64 66
65 // Returns an int which is a bitmask of kSandbox* values. Only valid after 67 // Returns an int which is a bitmask of kSandbox* values. Only valid after
66 // the first render has been forked. 68 // the first render has been forked.
67 int sandbox_status() const { 69 int sandbox_status() const {
68 if (have_read_sandbox_status_word_) 70 if (have_read_sandbox_status_word_)
69 return sandbox_status_; 71 return sandbox_status_;
(...skipping 17 matching lines...) Expand all
87 Lock control_lock_; 89 Lock control_lock_;
88 pid_t pid_; 90 pid_t pid_;
89 bool init_; 91 bool init_;
90 bool using_suid_sandbox_; 92 bool using_suid_sandbox_;
91 std::string sandbox_binary_; 93 std::string sandbox_binary_;
92 bool have_read_sandbox_status_word_; 94 bool have_read_sandbox_status_word_;
93 int sandbox_status_; 95 int sandbox_status_;
94 }; 96 };
95 97
96 #endif // CHROME_BROWSER_ZYGOTE_HOST_LINUX_H_ 98 #endif // CHROME_BROWSER_ZYGOTE_HOST_LINUX_H_
OLDNEW
« no previous file with comments | « chrome/browser/web_resource/web_resource_service.cc ('k') | chrome/browser/zygote_host_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698