CopyPastor

Detecting plagiarism made easy.

Score: 0.8839343899240096; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2019-08-22
by Shreyash Sharma

Original Post

Original - Posted on 2013-05-31
by Aya



            
Present in both answers; Present only in the new answer; Present only in the old answer;



Well, there are a couple of methods on the object returned by subprocess.Popen() which may be of use: Popen.terminate() and Popen.kill(), which send a SIGTERM and SIGKILL respectively.
For example...
import subprocess import time process = subprocess.Popen(cmd, shell=True) time.sleep(5) process.terminate()
...would terminate the process after five seconds.
Or you can use os.kill() to send other signals, like SIGINT to simulate CTRL-C, with...
import subprocess import time import os import signal process = subprocess.Popen(cmd, shell=True) time.sleep(5) os.kill(process.pid, signal.SIGINT)

Well, there are a couple of methods on the object returned by `subprocess.Popen()` which may be of use: [`Popen.terminate()`][1] and [`Popen.kill()`][2], which send a `SIGTERM` and `SIGKILL` respectively.
For example...
import subprocess import time process = subprocess.Popen(cmd, shell=True) time.sleep(5) process.terminate()
...would terminate the process after five seconds.
Or you can use [`os.kill()`][3] to send other signals, like `SIGINT` to simulate CTRL-C, with...
import subprocess import time import os import signal
process = subprocess.Popen(cmd, shell=True) time.sleep(5) os.kill(process.pid, signal.SIGINT)

[1]: http://docs.python.org/2/library/subprocess.html#subprocess.Popen.terminate [2]: http://docs.python.org/2/library/subprocess.html#subprocess.Popen.kill [3]: http://docs.python.org/2/library/os.html#os.kill

        
Present in both answers; Present only in the new answer; Present only in the old answer;