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

Side by Side Diff: content/browser/zygote_host/zygote_communication_linux.h

Issue 1617213002: Revert of Have each SandboxedProcessLauncherDelegate maintain a zygote. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_COMMON_ZYGOTE_COMMUNICATION_H_
6 #define CONTENT_COMMON_ZYGOTE_COMMUNICATION_H_
7
8 #include <set>
9 #include <vector>
10
11 #include "base/process/kill.h"
12 #include "base/synchronization/lock.h"
13 #include "content/common/content_export.h"
14 #include "content/public/browser/file_descriptor_info.h"
15
16 namespace content {
17
18 class CONTENT_EXPORT ZygoteCommunication {
19 public:
20 ZygoteCommunication();
21 ~ZygoteCommunication();
22
23 void Init();
24
25 // Tries to start a process of type indicated by process_type.
26 // Returns its pid on success, otherwise base::kNullProcessHandle;
27 pid_t ForkRequest(const std::vector<std::string>& command_line,
28 scoped_ptr<FileDescriptorInfo> mapping,
29 const std::string& process_type);
30
31 void EnsureProcessTerminated(pid_t process);
32
33 // Should be called every time a Zygote child died.
34 void ZygoteChildDied(pid_t process);
35
36 // Get the termination status (and, optionally, the exit code) of
37 // the process. |exit_code| is set to the exit code of the child
38 // process. (|exit_code| may be NULL.)
39 // Unfortunately the Zygote can not accurately figure out if a process
40 // is already dead without waiting synchronously for it.
41 // |known_dead| should be set to true when we already know that the process
42 // is dead. When |known_dead| is false, processes could be seen as
43 // still running, even when they're not. When |known_dead| is true, the
44 // process will be SIGKILL-ed first (which should have no effect if it was
45 // really dead). This is to prevent a waiting waitpid() from blocking in
46 // a single-threaded Zygote. See crbug.com/157458.
47 base::TerminationStatus GetTerminationStatus(base::ProcessHandle handle,
48 bool known_dead,
49 int* exit_code);
50
51 // Returns the sandbox status of this zygote.
52 int GetSandboxStatus();
53
54 private:
55 // Whether we should use the namespace sandbox instead of the setuid sandbox.
56 bool ShouldUseNamespaceSandbox();
57
58 // Should be called every time a Zygote child is born.
59 void ZygoteChildBorn(pid_t process);
60
61 // Read the reply from the zygote.
62 ssize_t ReadReply(void* buf, size_t buf_len);
63
64 // Sends |data| to the zygote via |control_fd_|. If |fds| is non-NULL, the
65 // included file descriptors will also be passed. The caller is responsible
66 // for acquiring |control_lock_|.
67 bool SendMessage(const base::Pickle& data, const std::vector<int>* fds);
68
69 // Get the sandbox status from the zygote.
70 ssize_t ReadSandboxStatus();
71
72 int control_fd_; // the socket to the zygote.
73 // A lock protecting all communication with the zygote. This lock must be
74 // acquired before sending a command and released after the result has been
75 // received.
76 base::Lock control_lock_;
77 // The pid of the zygote.
78 pid_t pid_;
79 // The list of running zygote children.
80 std::set<pid_t> list_of_running_zygote_children_;
81 // The lock to guard the list of running zygote children.
82 base::Lock child_tracking_lock_;
83 int sandbox_status_;
84 bool have_read_sandbox_status_word_;
85 bool use_suid_sandbox_for_adj_oom_score_;
86 // Set to true when the zygote is initialized successfully.
87 bool init_;
88 };
89
90 } // namespace content
91
92 #endif // CONTENT_COMMON_ZYGOTE_COMMUNICATION_H_
OLDNEW
« no previous file with comments | « content/browser/utility_process_host_impl.cc ('k') | content/browser/zygote_host/zygote_communication_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698