Skip to content

Conversation

@Satvik-Singh192
Copy link
Contributor

Fix Firewall Shutdown on Ctrl+C

Description

Fixed firewall process termination issue where repeated Ctrl+C inputs would trigger shutdown messages but the program would hang indefinitely.
Implemented robust signal handling with timeout mechanisms and proper thread management to ensure clean shutdown.


Changes Made

🔧 Core Fixes

  • Enhanced signal handler in main.py with timeout protection and state tracking
  • Improved thread management in core.py with coordinated shutdown using _stop_event
  • Better packet capture control using AsyncSniffer with immediate termination
  • Graceful degradation with force exit after timeout for stuck threads

🗂️ Files Modified

  • main.py – Added enhanced signal handler with global state tracking
  • core.py – Implemented proper thread termination and sniffer control

✨ New Features

  • Timeout protection: 5-second graceful shutdown window before force exit
  • State tracking: Prevents multiple signal handlers from interfering
  • Interruptible threads: Background threads check shutdown flag frequently
  • Force exit capability: Handles stubborn threads that don't terminate

Semver Changes

  • Patch (bug fix, no new features)
  • Minor (new features, no breaking changes)
  • Major (breaking changes)

Issues

Closes #1 – Firewall process does not terminate on Ctrl+C


@Satvik-Singh192
Copy link
Contributor Author

@utkarshkgithub please review my PR sir

@utkarshkgithub utkarshkgithub merged commit cbe413d into OPCODE-Open-Spring-Fest:main Nov 5, 2025
2 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants