From 2dc4940ca20ff9bfb896fa6b550435ff552012cb Mon Sep 17 00:00:00 2001 From: Smittix Date: Sun, 8 Feb 2026 16:30:51 +0000 Subject: [PATCH] Fix grgsm_scanner stdout buffering and increase scan timeout grgsm_scanner fully buffers stdout when piped, so scan results never reach Python until the buffer fills or process exits. Wrapping with stdbuf -oL forces line-buffered output for real-time data streaming. Also increased scan timeout from 120s to 300s since scanning 4 bands legitimately takes 2-3 minutes. Co-Authored-By: Claude Opus 4.6 --- routes/gsm_spy.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/routes/gsm_spy.py b/routes/gsm_spy.py index 524033f..8974273 100644 --- a/routes/gsm_spy.py +++ b/routes/gsm_spy.py @@ -373,7 +373,9 @@ def start_scanner(): return jsonify({'error': 'grgsm_scanner not found. Please install gr-gsm.'}), 500 try: - cmd = ['grgsm_scanner'] + # Use stdbuf to force line-buffered stdout - grgsm_scanner + # fully buffers stdout when piped, preventing real-time output + cmd = ['stdbuf', '-oL', 'grgsm_scanner'] # Add device argument (--args for RTL-SDR device selection) cmd.extend(['--args', f'rtl={device_index}']) @@ -1276,7 +1278,7 @@ def scanner_thread(cmd, device_index): # Process output with timeout scan_start = time.time() last_output = scan_start - scan_timeout = 120 # 2 minute maximum per scan + scan_timeout = 300 # 5 minute maximum per scan (4 bands takes ~2-3 min) while app_module.gsm_spy_scanner_running: # Check if process died