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

Side by Side Diff: sandbox/linux/services/scoped_process.h

Issue 670183003: Update from chromium 62675d9fb31fb8cedc40f68e78e8445a74f362e7 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « sandbox/linux/services/mips_linux_syscalls.h ('k') | sandbox/linux/services/scoped_process.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 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 SANDBOX_LINUX_SERVICES_SCOPED_PROCESS_H_
6 #define SANDBOX_LINUX_SERVICES_SCOPED_PROCESS_H_
7
8 #include "base/basictypes.h"
9 #include "base/callback_forward.h"
10 #include "base/process/process_handle.h"
11 #include "sandbox/sandbox_export.h"
12
13 namespace sandbox {
14
15 // fork() a child process that will run a Closure.
16 // After the Closure has run, the child will pause forever. If this object
17 // is detroyed, the child will be destroyed, even if the closure did not
18 // finish running. It's ok to signal the child from outside of this class to
19 // destroy it.
20 // This class cannot be instanciated from a multi-threaded process, as it needs
21 // to fork().
22 class SANDBOX_EXPORT ScopedProcess {
23 public:
24 // A new process will be created and |child_callback| will run in the child
25 // process. This callback is allowed to terminate the process or to simply
26 // return. If the callback returns, the process will wait forever.
27 explicit ScopedProcess(const base::Closure& child_callback);
28 ~ScopedProcess();
29
30 // Wait for the process to exit.
31 // |got_signaled| tells how to interpret the return value: either as an exit
32 // code, or as a signal number.
33 // When this returns, the process will still not have been reaped and will
34 // survive as a zombie for the lifetime of this object. This method can be
35 // called multiple times.
36 int WaitForExit(bool* got_signaled);
37
38 // Wait for the |child_callback| passed at construction to run. Return false
39 // if |child_callback| did not finish running and we know it never will (for
40 // instance the child crashed or used _exit()).
41 bool WaitForClosureToRun();
42 base::ProcessId GetPid() { return child_process_id_; }
43
44 private:
45 bool IsOriginalProcess();
46
47 base::ProcessId child_process_id_;
48 base::ProcessId process_id_;
49 int pipe_fds_[2];
50 DISALLOW_COPY_AND_ASSIGN(ScopedProcess);
51 };
52
53 } // namespace sandbox
54
55 #endif // SANDBOX_LINUX_SERVICES_SCOPED_PROCESS_H_
OLDNEW
« no previous file with comments | « sandbox/linux/services/mips_linux_syscalls.h ('k') | sandbox/linux/services/scoped_process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698