|
ascii-chat 0.8.38
Real-time terminal-based video chat with ASCII art conversion
|
Global application exit and signal handling API. More...
Go to the source code of this file.
Functions | |
| bool | should_exit (void) |
| void | signal_exit (void) |
| void | set_interrupt_callback (void(*cb)(void)) |
| void | setup_signal_handlers (void) |
Global application exit and signal handling API.
Provides a centralized exit mechanism and signal handler registration used by all modes (client, mirror, discovery) to coordinate graceful shutdown. All modes share a single global exit flag and interrupt callback.
Definition in file main.h.
| void set_interrupt_callback | ( | void(*)(void) | cb | ) |
Register a mode-specific interrupt callback
Called by mode-specific code to register a callback that will be invoked when signal_exit() is called. Used to shut down network sockets so threads blocked in recv() unblock quickly instead of waiting for timeouts.
The callback is called synchronously from signal_exit(), so it must be async-signal-safe (only atomics, socket_shutdown(), no malloc/etc).
Only one callback can be registered at a time. Setting a new callback replaces the previous one.
| cb | Function to call on exit signal, or NULL to unregister |
Definition at line 102 of file main.c.
Referenced by client_main(), and discovery_main().
| void setup_signal_handlers | ( | void | ) |
Set up global signal handlers
Called once at program startup in main() BEFORE mode dispatch. Registers:
SIGWINCH (terminal resize) is NOT registered here - client mode registers its own handler because it needs special processing.
Set up global signal handlers Called once at startup before mode dispatch
Definition at line 167 of file main.c.
Referenced by main().
| bool should_exit | ( | void | ) |
| void signal_exit | ( | void | ) |
Signal that the application should exit
Sets the global exit flag and calls the registered interrupt callback if set. Safe to call from signal handlers (uses only atomics and function pointers). Called by signal handlers (SIGTERM, Ctrl+C) and normal code (errors, timeouts).
Definition at line 94 of file main.c.