我有一个 python 脚本需要调用定义的$EDITOR
或$VISUAL
. 当单独调用 Python 脚本时,我可以$EDITOR
顺利启动,但是当我将某些内容传递给 Python 脚本时,$EDITOR
就无法启动。现在,我正在使用 nano 显示
收到 SIGHUP 或 SIGTERM
每次。这似乎与此处描述的问题相同。
sinister:Programming [1313]$ echo "import os;os.system('nano')" > "sample.py"
sinister:Programming [1314]$ python sample.py
# nano is successfully launched here.
sinister:Programming [1315]$ echo "It dies here." | python sample.py
Received SIGHUP or SIGTERM
Buffer written to nano.save.1
编辑:澄清;在程序内部,我没有向编辑器发送消息。代码如下:
editorprocess = subprocess.Popen([editor or "vi", temppath])
editorreturncode = os.waitpid(editorprocess.pid, 0)[1]