The tripe(8) server sends `SIGTERM' to its SLIP tunnel helpers when it
shuts down interfaces. This causes us to leave behind dead Unix-domain
sockets, which is bad. Catch `SIGTERM' so that we can clean up
properly -- and so that we can let clients pick up any remaining packets
we might still have queued.
#include <mLib/quis.h>
#include <mLib/report.h>
#include <mLib/sel.h>
+#include <mLib/sig.h>
#include <mLib/sub.h>
#include <mLib/tv.h>
}
}
+static void slip_term(int n, void *fdp)
+ { close_slip(*(int *)fdp); }
+
static void slipif(void)
{
int fd;
dstr d = DSTR_INIT;
struct sockaddr_un sun;
+ sig term;
size_t sz;
/* --- Make the socket --- */
dribble_out = make_dribbler(STDOUT_FILENO, done_slip_dribble, 0);
sel_addfile(&slip_in);
+ sig_init(&sel);
+ sig_add(&term, SIGTERM, slip_term, &fd);
+ sig_add(&term, SIGINT, slip_term, &fd);
+
initqueue(&q_in);
reasons++;