aboutsummaryrefslogtreecommitdiff
path: root/src/sandbox.py
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-09-12 17:08:25 +0200
committerCharles Cabergs <me@cacharle.xyz>2020-09-12 17:08:25 +0200
commit6026876cdfd8ffb1bde3c98e97bb7ba05ff4e4ae (patch)
treea625aa9203063b59600d6082b3bccc82fff5fda3 /src/sandbox.py
parent75f6b134911e378cb384e41fd0b9f717341acb2d (diff)
downloadminishell_test-6026876cdfd8ffb1bde3c98e97bb7ba05ff4e4ae.tar.gz
minishell_test-6026876cdfd8ffb1bde3c98e97bb7ba05ff4e4ae.tar.bz2
minishell_test-6026876cdfd8ffb1bde3c98e97bb7ba05ff4e4ae.zip
Moved parenthesis and operation in flow, Added sandbox context, Replaced subprocess wait by communicate to avoid dead lock
Diffstat (limited to 'src/sandbox.py')
-rw-r--r--src/sandbox.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/sandbox.py b/src/sandbox.py
index efad60c..8194556 100644
--- a/src/sandbox.py
+++ b/src/sandbox.py
@@ -6,7 +6,7 @@
# By: charles <me@cacharle.xyz> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/09/11 13:48:07 by charles #+# #+# #
-# Updated: 2020/09/11 20:25:38 by charles ### ########.fr #
+# Updated: 2020/09/12 17:06:28 by charles ### ########.fr #
# #
# ############################################################################ #
@@ -14,6 +14,7 @@ import os
import glob
import shutil
import subprocess
+from contextlib import contextmanager
import config
@@ -35,3 +36,11 @@ def remove():
except PermissionError:
subprocess.run(["chmod", "777", *glob.glob(config.SANDBOX_PATH + "/*")], check=True)
subprocess.run(["rm", "-rf", config.SANDBOX_PATH], check=True)
+
+
+@contextmanager
+def context():
+ """Sandbox context manager"""
+ create()
+ yield
+ remove()