- commit
- 0b2df2b
- parent
- bac7930
- author
- Eric Bower
- date
- 2025-12-03 23:11:22 -0500 EST
fix: send SIGTERM to pty child process before shutting down The issue was that when `zmx kill` was called, the daemon would call `shutdown()` and exit the loop, but then get stuck at `waitpid(daemon.pid, 0)` waiting for the PTY child shell to exit. Since the shell was never killed, the daemon would hang forever, preventing the defer block from running that deletes the socket file. The fix sends SIGTERM to the PTY child process before shutting down, allowing the shell to exit gracefully so waitpid returns and the socket cleanup defer runs. References: https://github.com/neurosnap/zmx/issues/10
1 files changed,
+3,
-0
+3,
-0
1@@ -771,6 +771,9 @@ fn daemonLoop(daemon: *Daemon, server_sock_fd: i32, pty_fd: i32) !void {
2 },
3 .Kill => {
4 std.log.info("kill received session={s}", .{daemon.session_name});
5+ posix.kill(daemon.pid, posix.SIG.TERM) catch |err| {
6+ std.log.warn("failed to send SIGTERM to pty child err={s}", .{@errorName(err)});
7+ };
8 daemon.shutdown();
9 should_exit = true;
10 break :clients_loop;