If MariaDB receives SIGTERM after the call to start_signal_handler() but before the call to init_slave() then kill_server_thread() will call close_connections() (through kill_server() ) which will ask all threads to terminate and will start to wait on COND_thread_count. After that init_slave() will be called, it will call run_slave_init_thread(), which will launch handle_slave_init() and will start to wait on COND_thread_count too. At this point if handle_slave_init() calls mysql_cond_signal(&COND_thread_count) then it can wake up close_connections() which will do nothing and return back to sleep. But run_slave_init_thread() will remain sleeping and no one will ever wake it up, MariaDB will hang forever with "kill -9" as the only chance to exit.
So the call to mysql_cond_signal(&COND_thread_count) in the handle_slave_init() should be changed to mysql_cond_broadcast(&COND_thread_count).
Note that calling *_broadcast instead of *_signal matches all other usages of COND_thread_count throughout MariaDB code.