Properly handle the socket redirections

This commit is contained in:
Nick Chambers 2021-07-06 00:29:17 -05:00 committed by Nick Chambers
parent 85694429ee
commit 6164d713df
1 changed files with 6 additions and 1 deletions

7
rowbot
View File

@ -297,7 +297,7 @@ on_sys_first_002_net() {
socat "$conn_args" - <"$sock_dir"/rowbot-in.sock >"$sock_dir"/rowbot-out.sock &
tls_pid=$!
exec {out_sock}>"$sock_dir"/rowbot-out.sock {in_sock}<"$sock_dir"/rowbot-in.sock
exec {out_sock}>"$sock_dir"/rowbot-in.sock {in_sock}<"$sock_dir"/rowbot-out.sock
log_debug "process %d is handling tls" "$tls_pid"
fi
}
@ -308,6 +308,11 @@ on_sys_exit_998_net() {
exec {irc_sock}>&-
else
log_info "rowbot is closing the connection to ircs://%s:%s" "${config[server]}" "${config[port]}"
if [[ -v tls_pid ]]; then
kill -INT "$tls_pid"
fi
rm -rf -- "$sock_dir"
fi
}