如何在python中将EOF写入STDIN popen

gud*_*dge 11 python subprocess popen whiptail

我有以下命令通过popen运行:

p = subprocess.popen(["/usr/bin/whiptail", "--title", "\"Progress\"", "--gauge", "\"\"", "6", "50", "0"], stdout=subprocess.PIPE, stding=subprocess.PIPE)
Run Code Online (Sandbox Code Playgroud)

要停止whiptail命令运行,我需要将EOF发送到stdin.

如何在Python中将EOF发送到stdin?

或者我只是调用p.terminate()

let*_*bee 13

您需要的是关闭用作脚本标准输入的文件.

所以在你的情况下它是p.stdin.close().