mirror of
https://github.com/chubin/cheat.sh.git
synced 2025-01-05 20:04:38 +03:00
connect stdin to /dev/null when starting subprocesses
This commit is contained in:
parent
0243dce889
commit
f44b58d8ac
@ -56,7 +56,6 @@ class Question(UpstreamAdapter):
|
||||
section_name = SO_NAME.get(section_name, section_name)
|
||||
topic = "%s/%s" % (section_name, topic)
|
||||
|
||||
|
||||
# some clients send queries with - instead of + so we have to rewrite them to
|
||||
topic = re.sub(r"(?<!-)-", ' ', topic)
|
||||
|
||||
@ -91,7 +90,7 @@ class Question(UpstreamAdapter):
|
||||
topic = [topic]
|
||||
|
||||
cmd = [CONFIG["path.internal.bin.upstream"]] + topic
|
||||
proc = Popen(cmd, stdout=PIPE, stderr=PIPE)
|
||||
proc = Popen(cmd, stdin=open(os.devnull, "r"), stdout=PIPE, stderr=PIPE)
|
||||
answer = proc.communicate()[0].decode('utf-8')
|
||||
return answer
|
||||
|
||||
|
@ -195,7 +195,7 @@ def _run_vim_script(script_lines, text_lines):
|
||||
|
||||
cmd = ["script", "-q", "-c",
|
||||
"vim -S %s %s" % (script_vim.name, textfile.name)]
|
||||
Popen(cmd, shell=False, stdout=FNULL, stderr=FNULL, env=my_env).communicate()
|
||||
Popen(cmd, shell=False, stdin=FNULL, stdout=FNULL, stderr=FNULL, env=my_env).communicate()
|
||||
|
||||
return open(textfile.name, "r").read()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user