Python Forum
os.kill - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: os.kill (/thread-23979.html)



os.kill - elstolbo - Jan-25-2020

hello programmers.
I will develop an application to serve as a network tester and one of the parts of this application will be tshark, which is used to monitor packets in the network.
It all works fine, but there is a problem with stopping this process. I use os.kill (PID, SIGKILL) for that.

def tshark_stop():
        out = subprocess.getoutput("ps ax | tshark | grep -v grep").split("\n")
        for line in out:
                fields = line.split()
                pid = fields[0]
                os.kill(int(pid), signal.SIGKILL)
When I try this through the console in the command line, everything works as it should, but when I run this command through my application, the whole application freezes and nothing can be done with it and the only solution is to turn off the whole application and turn it on again. undesirable.
Do you know why os.kill freezes the whole application ??
thank you for answer


RE: os.kill - ibreeden - Jan-26-2020

Are you not missing a keyword?
  out = subprocess.getoutput("ps ax | tshark | grep -v grep").split("\n")
  ... should be:
  out = subprocess.getoutput("ps ax | grep tshark | grep -v grep").split("\n")