I have the following command run through popen:
p = subprocess.popen(["/usr/bin/whiptail", "--title", "\"Progress\"", "--gauge", "\"\"", "6", "50", "0"], stdout=subprocess.PIPE, stding=subprocess.PIPE)
To stop the whiptail command from running I need to send EOF to stdin.
How do I send EOF to stdin in Python ?
or I just call p.terminate()
The subprocess module defines one class, Popen and a few wrapper functions that use that class. The constructor for Popen takes arguments to set up the new process so the parent can communicate with it via pipes. It provides all of the functionality of the other modules and functions it replaces, and more.
Python method popen() opens a pipe to or from command. The return value is an open file object connected to the pipe, which can be read or written depending on whether mode is 'r' (default) or 'w'. The bufsize argument has the same meaning as in open() function.
Popen Function The popen() function will execute the command supplied by the string command. The function should return a pointer to a stream that may be used to read from or write to the pipe while also creating a pipe between the calling application and the executed command.
What you need is to close the file used as standard input for your script.
So in your case it's p.stdin.close()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With