diff --git a/src/ck-sysdeps-unix.c b/src/ck-sysdeps-unix.c index 0001b6b..bcdfb21 100644 --- a/src/ck-sysdeps-unix.c +++ b/src/ck-sysdeps-unix.c @@ -267,7 +267,13 @@ ck_wait_for_active_console_num (int console_fd, g_debug ("Interrupted waiting for native console %d activation: %s", num, errmsg); +#if !defined(__FreeBSD__) + /* We don't want to retry on FreeBSD since getting + * EINTR means we are terminating, and we don't want + * to keep restarting our active VT check. + */ goto again; +#endif } else { g_warning ("Error waiting for native console %d activation: %s", num, diff --git a/src/main.c b/src/main.c index 11b6f2e..af2998b 100644 --- a/src/main.c +++ b/src/main.c @@ -245,6 +245,27 @@ setup_debug_log_signals (void) } static void +terminate (int sig __unused) +{ + return; +} + +static void +setup_termination_signals (void) +{ + struct sigaction sa; + + sa.sa_handler = terminate; + sigemptyset (&sa.sa_mask); + sa.sa_flags = 0; + + sigaction (SIGTERM, &sa, NULL); + sigaction (SIGQUIT, &sa, NULL); + sigaction (SIGINT, &sa, NULL); + sigaction (SIGHUP, &sa, NULL); +} + +static void setup_debug_log (gboolean debug) { ck_log_init (); @@ -300,6 +321,8 @@ main (int argc, setup_debug_log (debug); + setup_termination_signals (); + connection = get_system_bus (); if (connection == NULL) { goto out; diff --git a/src/test-vt-monitor.c b/src/test-vt-monitor.c index c445865..e31b24e 100644 --- a/src/test-vt-monitor.c +++ b/src/test-vt-monitor.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -47,6 +48,12 @@ activated_cb (CkVtMonitor *monitor, g_message ("VT %u activated", num); } +static void +terminate (int sig __unused) +{ + return; +} + int main (int argc, char **argv) { @@ -55,12 +62,22 @@ main (int argc, char **argv) GError *error; guint num; gboolean res; + struct sigaction sa; if (! g_thread_supported ()) { g_thread_init (NULL); } g_type_init (); + sa.sa_handler = terminate; + sigemptyset (&sa.sa_mask); + sa.sa_flags = 0; + + sigaction (SIGINT, &sa, NULL); + sigaction (SIGTERM, &sa, NULL); + sigaction (SIGQUIT, &sa, NULL); + sigaction (SIGHUP, &sa, NULL); + if (! ck_is_root_user ()) { g_warning ("Must be run as root"); exit (1);