Developing and testing on Windows 7, created Sublime Text 3 plugin and opened subprocess:
proc = subprocess.Popen("node" , myJSFile], cwd=dirname, bufsize=-1, stdout=subprocess.PIPE , stderr=subprocess.PIPE , shell=True , universal_newlines=True)
NB: I need the shell=true.
Subprocess runs nicely but when I try to kill it by sending it SIGTERM:
os.kill(proc.pid , signal.SIGTERM)
I get the following error:
Traceback (most recent call last):
File "D:\Portable\Sublime Text 3\sublime_plugin.py", line 549, in run_
return self.run(edit)
File "D:\Portable\Sublime Text 3\Data\Packages\NodeRunner\NodeRunner.py", line 50, in run
terminateNode(entryPoint)
File "D:\Portable\Sublime Text 3\Data\Packages\NodeRunner\NodeRunner.py", line 98, in terminateNode
os.kill(proc.pid , signal.SIGTERM)
PermissionError: [WinError 5] Access is denied
Currently, I can kill the process with:
subprocess.Popen("taskkill /F /T /PID %i"%proc.pid , shell=True)
But I dont like this brute force solution as my process does not get proper sigterm signal for post operations.
I have read lot of google topics about the subject but with no success. Does anyone have any ideas how to solve?