def stop_capture(self): """Kill the dumpcap process.""" ut.kill_all_children(self.p0.pid) # self.p0.pid is the shell pid self.p0.kill() self.is_recording = False if os.path.isfile(self.pcap_file): wl_log.info('Capture killed. Traffic size: %s Bytes %s' % (os.path.getsize(self.pcap_file), self.pcap_file)) else: wl_log.warning('Capture killed but cannot find capture file: %s' % self.pcap_file) wl_log.warning('Check %s for error information!' % self.log)
def test_kill_all_children(self): parent = subprocess.Popen('/bin/sleep 1', shell=True) ut.kill_all_children(parent.pid) children = len(list(ut.gen_all_children_procs(parent.pid))) self.assertEqual(children, 0)