python - Killing process on Ubuntu with os.system() issue -


i try send command python shell ubuntu os define process existed on particular port , kill it:

port = 8000 os.system("netstat -lpn | grep %s" % port) 

output:

tcp 0 0 127.0.0.1.8000 0.0.0.0:* listen 22000/python

then:

os.system("kill -sigterm 22000") 

but got following trace

sh: 1: kill: illegal option -s

for reason command can not transferred os full signal -sigterm, -s. can kill process directly terminal, seems it's python or os issue... how can run kill command using python? appreciated

you try using

import signal os.kill(process.pid, signal.sigkill) 

documentation can found here.

you use signal.ctrl_c_event, corresponds ctrl+c keystroke event.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -