448f1ed1d5
Issue: All completed scans showing as "RUNNING" in status check User reported 5 scans showing RUNNING when they actually completed hours ago, with 0 scans showing as COMPLETED despite being done. Root Cause: Line 1851 used: `pgrep -f "$dir/scan.sh"` This pattern matches ANY process with that path in its command line: - The actual scan.sh process (correct) - Shell sessions viewing results (false positive) - Editors/viewers with the file open (false positive) - grep/tail commands on logs (false positive) - Any process that touched those files (false positive) This caused completed scans to always show as "RUNNING" because there were always SOME processes matching the overly broad pattern. Evidence from User's Status Check: malware-20251222-202658 [RUNNING] Latest: "Scan session ended - opening interactive shell" Scan says "ended" but status shows RUNNING - clear false positive! Solution - Two-part Fix: 1. Use More Specific Process Match: Changed from: pgrep -f "$dir/scan.sh" Changed to: pgrep -f "bash $dir/scan.sh" This only matches actual bash execution of the script, not viewers, editors, or other processes. 2. Add Marker File for Reliability: Create .scan_running marker when scan starts Remove .scan_running marker when scan exits (in cleanup trap) Status check: pgrep OR marker file = running This handles edge cases where process check might fail but provides definitive state tracking. Changes: 1. check_standalone_status() (line 1852): - Added "bash " prefix to pgrep pattern - Added OR check for .scan_running marker file - Both in running detection and delete listing 2. Standalone scan.sh template (lines 655, 607): - Create marker: touch "$SCAN_DIR/.scan_running" after start - Remove marker: rm -f "$SCAN_DIR/.scan_running" in cleanup_on_exit 3. delete_standalone_sessions() (line 1917): - Same pgrep + marker file logic for consistency Result: Now completed scans will correctly show [COMPLETED] status instead of falsely showing [RUNNING] due to viewer processes. Status detection is now accurate and reliable!