Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
os.kill
#1
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
Reply
#2
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")
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to Kill Dead Loop of "while" cheers100 4 2,749 Aug-22-2019, 09:30 AM
Last Post: cheers100

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020