-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Labels
Description
Project
vgrep
Description
The file watcher in src/watcher.rs line 65 uses .expect() when setting up the Ctrl+C handler. This can panic and crash the application when running in environments where signal handlers cannot be set (e.g., certain containerized environments, non-TTY contexts, or when another handler is already registered).
Error Message
thread 'main' panicked at 'Error setting Ctrl+C handler: ...'Debug Logs
System Information
- Bounty Version: 0.1.0
- OS: Ubuntu 24.04 LTS
- Rust: 1.75+Screenshots
No response
Steps to Reproduce
- Run vgrep watch in a non-TTY environment:
or
echo "" | vgrep watch
vgrep watch < /dev/null - In some environments, this will panic when trying to set the signal handler
Expected Behavior
The application should handle signal handler setup failures gracefully:
- Log a warning that graceful shutdown won't work
- Continue running without the signal handler
- Document alternative ways to stop the watcher (kill -9, etc.)
Actual Behavior
Application panics and terminates if signal handler cannot be set, preventing the watcher from running at all in certain environments.
Additional Context
Environments where this might fail:
- Docker containers without TTY (
docker runwithout-it) - CI/CD pipelines
- Background service execution
- Environments with existing signal handlers
- Some Windows configurations
The ctrlc crate itself documents that set_handler can fail in various scenarios. Using .expect() is overly strict for what is essentially a convenience feature.