forked from rust-lang/rust-playpen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
playpen.py
executable file
·23 lines (21 loc) · 882 Bytes
/
playpen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python3
import subprocess
def execute(version, command, arguments, data=None):
with subprocess.Popen(("playpen",
"root-" + version,
"--mount-proc",
"--user=rust",
"--timeout=5",
"--syscalls-file=whitelist",
"--devices=/dev/urandom:r,/dev/null:w",
"--memory-limit=128",
"--",
command) + arguments,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT) as p:
if data is None:
out = p.communicate()[0]
else:
out = p.communicate(data.encode())[0]
return (out, p.returncode)