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

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

Issue 188193002: Linux sandbox: add basic Yama support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Add testing. Created 6 years, 9 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
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.h"
10 #include "base/process/process_handle.h"
11
12 namespace sandbox {
13
14 // fork() a child process that will run a Closure. After the Closure
15 // has run, the child will exit. If this object goes out of scope, the child
16 // will be destroyed, even if the closure did not finish running.
17 class ScopedProcess {
18 public:
19 // |child_callback| will run in the child process. It can simply return
20 // in which case the child process will exit normally. Or it can use
21 // _exit(2) to exit.
22 explicit ScopedProcess(const base::Closure& child_callback);
23 ~ScopedProcess();
24
25 // Wait for the process to exit, that is, wait for the closure to finish
26 // running.
27 // |got_signaled| tells how to interpret the return value: either as an exit
28 // code, or as a signal number.
29 int WaitForExit(bool* got_signaled);
30 base::ProcessId GetPid() { return child_process_id_; }
31
32 private:
33 bool IsOriginalProcess();
34
35 base::Closure child_callback_;
36 base::ProcessId child_process_id_;
37 base::ProcessId process_id_;
38 DISALLOW_COPY_AND_ASSIGN(ScopedProcess);
39 };
40
41 } // namespace sandbox
42
43 #endif // SANDBOX_LINUX_SERVICES_SCOPED_PROCESS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698