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 #ifndef CONTENT_PUBLIC_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_ | 5 #ifndef CONTENT_PUBLIC_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_ |
6 #define CONTENT_PUBLIC_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_ | 6 #define CONTENT_PUBLIC_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_ |
7 | 7 |
8 #include <unistd.h> | 8 #include <unistd.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // http://code.google.com/p/chromium/wiki/LinuxZygote | 52 // http://code.google.com/p/chromium/wiki/LinuxZygote |
53 kDummyFDIndex, | 53 kDummyFDIndex, |
54 kParentFDIndex, | 54 kParentFDIndex, |
55 kNumPassedFDs // Number of FDs in the vector passed to Fork(). | 55 kNumPassedFDs // Number of FDs in the vector passed to Fork(). |
56 }; | 56 }; |
57 | 57 |
58 // Delegate forks, returning a -1 on failure. Outside the | 58 // Delegate forks, returning a -1 on failure. Outside the |
59 // suid sandbox, Fork() returns the Linux process ID. | 59 // suid sandbox, Fork() returns the Linux process ID. |
60 // This method is not aware of any potential pid namespaces, so it'll | 60 // This method is not aware of any potential pid namespaces, so it'll |
61 // return a raw pid just like fork() would. | 61 // return a raw pid just like fork() would. |
62 virtual pid_t Fork(const std::vector<int>& fds) = 0; | 62 virtual pid_t Fork(const std::string& process_type, |
| 63 const std::vector<int>& fds) = 0; |
63 | 64 |
64 // After a successful fork, signal the child to indicate that | 65 // After a successful fork, signal the child to indicate that |
65 // the child's PID has been received. Also communicate the | 66 // the child's PID has been received. Also communicate the |
66 // channel switch as a part of acknowledgement message. | 67 // channel switch as a part of acknowledgement message. |
67 virtual bool AckChild(int fd, const std::string& channel_switch) = 0; | 68 virtual bool AckChild(int fd, const std::string& channel_switch) = 0; |
68 | 69 |
69 // The fork delegate must also assume the role of waiting for its children | 70 // The fork delegate must also assume the role of waiting for its children |
70 // since the caller will not be their parents and cannot do it. |pid| here | 71 // since the caller will not be their parents and cannot do it. |pid| here |
71 // should be a pid that has been returned by the Fork() method. i.e. This | 72 // should be a pid that has been returned by the Fork() method. i.e. This |
72 // method is completely unaware of eventual PID namespaces due to sandboxing. | 73 // method is completely unaware of eventual PID namespaces due to sandboxing. |
73 // |known_dead| indicates that the process is already dead and that a | 74 // |known_dead| indicates that the process is already dead and that a |
74 // blocking wait() should be performed. In this case, GetTerminationStatus() | 75 // blocking wait() should be performed. In this case, GetTerminationStatus() |
75 // will send a SIGKILL to the target process first. | 76 // will send a SIGKILL to the target process first. |
76 virtual bool GetTerminationStatus(pid_t pid, bool known_dead, | 77 virtual bool GetTerminationStatus(pid_t pid, bool known_dead, |
77 base::TerminationStatus* status, | 78 base::TerminationStatus* status, |
78 int* exit_code) = 0; | 79 int* exit_code) = 0; |
79 }; | 80 }; |
80 | 81 |
81 } // namespace content | 82 } // namespace content |
82 | 83 |
83 #endif // CONTENT_PUBLIC_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_ | 84 #endif // CONTENT_PUBLIC_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_ |
OLD | NEW |