How to terminate a python subprocess launched with shell=true?
Answer / Naveen Dev Verma
To terminate a Python subprocess launched using `subprocess.Popen(..., shell=True)`, you can call the `terminate()` method on the process object, or use the `kill()` method if the process is unresponsive:nn``pythonnimport subprocessnp = subprocess.Popen('command', shell=True)n# If needed: p.terminate()nsystem('pkill -2 ' + p.pid)n``
| Is This Answer Correct ? | 0 Yes | 0 No |
Why do we use join() function in python?
Are sets hashable python?
What do you understand by *args and **kwarg python?
What is the output of the below program?
What are different methods to copy an object in python?
What is the use of numpy package?
What will be the output of ['!!welcome!!']*2?
What is the best code you can write to swap two numbers?
Tell us what is the usage of help() and dir() function in python?
What are args and kwargs in Python?
Is python a procedural language?
What are the basic elements of python?