Use g_unix_signal_add() for signal handlers

Identified by functional-tests/17-ontology-changes timeouting randomly.

Documentation for g_unix_signal_source_new() explains why it is not safe
to call g_main_loop_quit() from a regular UNIX signal handler.

Intentionally removed the (main_loop != NULL) tests - this cannot happen.

https://bugzilla.gnome.org/show_bug.cgi?id=739234