I have a class which can start and close a process. However it seems not to close the process.
My python code, there are other methods but they work fine.:
class KismetInstance:
"""Creates a kismet_server instance"""
def __init__(self, value=False):
logging.basicConfig(format='%(asctime)-15s::: %(message)s')
self.logger = logging.getLogger('kismet_instance')
self.example = value
def __create_kismet_instance__(self):
"""
Create a kismet_server subprocess.
:return:
"""
shell = ['sudo', '/usr/local/bin/kismet_server']
self.logger.debug('Attempting to run: %s', " ".join(shell))
self.kismet = Popen(shell, stdin=PIPE, stdout=PIPE, stderr=PIPE, cwd=r'./logs', preexec_fn=os.setsid)
def __destroy_kismet_instance__(self):
"""
Kill the subprocess
:return:
"""
os.killpg(os.getpgid(self.kismet.pid), 15)
It can create the subprocess fine. But I get this error when I try to kill (no sudo)
OSError: [Errno 1] Operation not permitted
And if I run with sudo, the process is still running afterwards.
pi@raspberrypi ~/project $ ps -A | grep 'kismet'
2912 ? 00:00:00 kismet_server