Skip to content

Commit 8a1363d

Browse files
committed
Stopping abandoned subprocesses
1 parent a1cff40 commit 8a1363d

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

languages.sublime-settings

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
},
66
"lang-cpp" : {
77
"compile_cmd" : "g++ \"${code_file}\" -o \"${code_file_path}/${code_file_base_name}\"",
8-
"execute_cmd" : "\"${code_file_path}/${code_file_base_name}\"",
8+
"execute_cmd" : "${code_file_path}/${code_file_base_name}",
99
"timeout" : 3
1010
},
1111
"lang-java" : {

run.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
import subprocess
55
from string import Template
6+
import shlex
67

78
DEFAULT_LAYOUT = {"cols": [0.0, 1.0], "rows": [0.0, 1.0], "cells": [[0, 0, 1, 1]]}
89
IO_PANE_LAYOUT = {"cols": [0.0, 0.5, 1.0], "rows": [0.0, 0.75, 0.75, 1.0],
@@ -79,15 +80,15 @@ def compile(output_view):
7980
code_file_path=Environment.file_path, code_file=Environment.file)
8081

8182
output_view.run_command("output_file_edit", {"append": "Compiling ...\n"});
82-
compile = subprocess.Popen(compile_command,
83-
shell=True,
83+
compile = subprocess.Popen(shlex.split(compile_command),
84+
# shell=True,
8485
stdin=subprocess.PIPE,
8586
stdout=subprocess.PIPE,
8687
stderr=subprocess.STDOUT,
8788
universal_newlines=True
8889
)
89-
compile.wait();
90-
output_view.run_command("output_file_edit", {"append": compile.args + "\n\n"});
90+
print(type(compile.args))
91+
output_view.run_command("output_file_edit", {"append": ''.join(compile.args) + "\n\n"});
9192
output, errors = compile.communicate()
9293
output_view.run_command("output_file_edit", {"append": "\n" + output + "\n\n"});
9394
output_view.run_command("output_file_edit",
@@ -108,14 +109,14 @@ def execute(input_view, output_view):
108109
code_file_path=Environment.file_path, code_file=Environment.file)
109110

110111
output_view.run_command("output_file_edit", {"append": "Running ...\n"});
111-
run = subprocess.Popen(execute_command,
112-
shell=True,
112+
run = subprocess.Popen(shlex.split(execute_command),
113+
# shell=True,
113114
stdin=subprocess.PIPE,
114115
stdout=subprocess.PIPE,
115116
stderr=subprocess.STDOUT,
116117
universal_newlines=True
117118
)
118-
output_view.run_command("output_file_edit", {"append": run.args + "\n\n"});
119+
output_view.run_command("output_file_edit", {"append": ''.join(run.args) + "\n\n"});
119120
output = None
120121
timeout = DEFAULT_TIMEOUT
121122
if "timeout" in lang_settings:

0 commit comments

Comments
 (0)