Index: sandbox.cc |
=================================================================== |
--- sandbox.cc (revision 179) |
+++ sandbox.cc (working copy) |
@@ -11,6 +11,7 @@ |
namespace playground { |
// Global variables |
+int Sandbox::proc_self_ = -1; |
int Sandbox::proc_self_maps_ = -1; |
enum Sandbox::SandboxStatus Sandbox::status_ = STATUS_UNKNOWN; |
int Sandbox::pid_; |
@@ -217,7 +218,7 @@ |
sys.close(devnull); |
} |
if (proc_fd >= 0) { |
- setProcSelfMaps(sys.openat(proc_fd, "self/maps", O_RDONLY, 0)); |
+ setProcSelf(sys.openat(proc_fd, "self", O_RDONLY|O_DIRECTORY, 0)); |
} |
startSandbox(); |
write(sys, fds[1], "", 1); |
@@ -250,8 +251,8 @@ |
} |
} |
-void Sandbox::setProcSelfMaps(int proc_self_maps) { |
- proc_self_maps_ = proc_self_maps; |
+void Sandbox::setProcSelf(int proc_self) { |
Mark Seaborn
2012/04/27 23:07:38
The smallest change would be to make setProcSelf()
Markus (顧孟勤)
2012/04/28 01:15:43
That actually breaks the existing API in a subtle
|
+ proc_self_ = proc_self; |
} |
void Sandbox::startSandbox() { |
@@ -262,6 +263,11 @@ |
} |
SysCalls sys; |
+ if (proc_self_ >= 0) { |
+ proc_self_maps_ = sys.openat(proc_self_, "maps", O_RDONLY, 0); |
+ NOINTR_SYS(sys.close(proc_self_)); |
jln (very slow on Chromium)
2012/04/27 23:08:20
Should we check for close() errors here ? Since th
|
+ proc_self_ = -1; |
+ } |
if (proc_self_maps_ < 0) { |
proc_self_maps_ = sys.open("/proc/self/maps", O_RDONLY, 0); |
if (proc_self_maps_ < 0) { |