pub fn exec_reload(
raw_fd: RawFd,
nick: &str,
server: &str,
channels: &[String],
keepalive_interval_ms: u64,
keepalive_timeout_ms: u64,
) -> BoxErrorExpand description
Hot-reload support: replace the running bot binary without dropping the IRC connection.
ยงHow it works
On Unix, a TCP socket is just an open file descriptor. When a process
calls exec() the new process image inherits all file descriptors that do
not have the FD_CLOEXEC flag set.
exec_reload exploits this:
- Clears
FD_CLOEXECon the live TCP socket fd so the new binary inherits it. - Serialises the connection metadata (fd number, nick, server, channels, keepalive settings) into environment variables.
- Calls
exec()to replace the current process image with the new binary. The PID does not change; the TCP connection is never closed.
The new binary calls crate::connection::State::try_inherit_from_env
at startup. If the env vars are present it reconstructs a live State
from the inherited fd instead of opening a new TCP connection.
This is the Unix-only implementation. On non-Unix targets the function is
a no-op that returns Err.