diff options
-rw-r--r-- | src/dillo.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/dillo.cc b/src/dillo.cc index 0b04e804..47c4ba25 100644 --- a/src/dillo.cc +++ b/src/dillo.cc @@ -69,6 +69,7 @@ #include "dw/table.hh" static volatile sig_atomic_t sig_reload = 0; +static volatile sig_atomic_t sig_exit = 0; /** * Command line options structure @@ -155,6 +156,11 @@ static void handler_usr1(int signum) sig_reload = 1; } +static void handler_usr2(int signum) +{ + sig_exit = 1; +} + /** * Establish SIGCHLD handler */ @@ -176,6 +182,15 @@ static void est_sigchld(void) perror("signal failed"); exit(1); } + + /* For now we use SIGUSR2 to exit cleanly, so we can run the + * automatic HTML test and check that there are no leaks. In the + * future we should use a better communication mechanism. This + * feature is not documented, as it is intended for testing only. */ + if (signal(SIGUSR2, handler_usr2) == SIG_ERR) { + perror("signal failed"); + exit(1); + } } //---------------------------------------------------------------------------- @@ -605,6 +620,8 @@ int main(int argc, char **argv) if (sig_reload) { sig_reload = 0; a_UIcmd_reload_all_active(); + } else if (sig_exit) { + break; } } |