Signal Handler Setup Method: Moved signal handler setup to its own method for clarity.
Controller Lifecycle Management: Added proper lifecycle management for the StreamController, ensuring terminal settings are reset on stream cancellation.
Exit on Signal: Added exit(0); in _resetTerminalSettings to ensure the application exits gracefully after cleaning up.
Error Logging: Used stderr.writeln instead of print for error messages to ensure they go to the standard error stream.
Platform Independence: Signal handling for sigint and sigterm properly checked for Windows compatibility.
Documentation: Added comments for better understanding and maintainability.
Signal Handler Setup Method: Moved signal handler setup to its own method for clarity.
Controller Lifecycle Management: Added proper lifecycle management for the StreamController, ensuring terminal settings are reset on stream cancellation.
Exit on Signal: Added exit(0); in _resetTerminalSettings to ensure the application exits gracefully after cleaning up.
Error Logging: Used stderr.writeln instead of print for error messages to ensure they go to the standard error stream.
Platform Independence: Signal handling for sigint and sigterm properly checked for Windows compatibility.
Documentation: Added comments for better understanding and maintainability.