(process_key)
| 34 | |
| 35 | # Function to kill a running process |
| 36 | def kill_process(process_key): |
| 37 | process = running_processes.get(process_key) |
| 38 | if process and process.poll() is None: # Check if process exists and is still running |
| 39 | try: |
| 40 | # Try to terminate gracefully first |
| 41 | process.terminate() |
| 42 | |
| 43 | # Wait a bit for process to terminate |
| 44 | try: |
| 45 | process.wait(timeout=3) |
| 46 | except subprocess.TimeoutExpired: |
| 47 | # If still running, force kill |
| 48 | process.kill() |
| 49 | |
| 50 | running_processes[process_key] = None |
| 51 | update_status(f"{process_key.replace('_', ' ').title()} stopped") |
| 52 | return True |
| 53 | except Exception as e: |
| 54 | messagebox.showerror("Error", f"Failed to stop {process_key}: {e}") |
| 55 | return False |
| 56 | else: |
| 57 | messagebox.showinfo("Info", f"No running {process_key.replace('_', ' ').title()} process found") |
| 58 | running_processes[process_key] = None |
| 59 | return False |
| 60 | |
| 61 | # Function to show the gesture submenu |
| 62 | def show_gesture_submenu(): |
no test coverage detected