X-Git-Url: https://git.distorted.org.uk/~mdw/tripe/blobdiff_plain/c9aded9f1c5c6eea294bf85e5e34efb9f52138c6..917c5c17c0321c7ebd31737261a62de768da4a75:/server/tripe.c diff --git a/server/tripe.c b/server/tripe.c index b4f4cc97..0252aa69 100644 --- a/server/tripe.c +++ b/server/tripe.c @@ -38,6 +38,7 @@ static sel_timer it; static unsigned iv_nreasons = 0; static struct timeval iv_next = { 0, 0 }; +static int lpdone = 0; /*----- The interval timer ------------------------------------------------*/ @@ -121,6 +122,17 @@ void lp_init(void) sig_init(&sel); } +/* --- @lp_end@ --- * + * + * Arguments: --- + * + * Returns: --- + * + * Use: Requests an exit from the main loop. + */ + +void lp_end(void) { lpdone = 1; } + /* --- @lp_run@ --- * * * Arguments: --- @@ -136,6 +148,7 @@ int lp_run(void) for (;;) { a_preselect(); + if (lpdone) break; if (!sel_select(&sel)) nerr = 0; else if (errno != EINTR && errno != EAGAIN) { a_warn("SERVER", "select-error", "?ERRNO", A_END); @@ -146,6 +159,7 @@ int lp_run(void) } } } + lpdone = 0; return (0); } @@ -418,9 +432,11 @@ int main(int argc, char *argv[]) a_switcherr(); } - iv_addreason(); - lp_run(); + + p_destroyall(); + a_unlisten(); + ps_quit(); return (0); }