ctdb-cluster-mutex: Block signals around fork
authorMartin Schwenke <martin@meltin.net>
Wed, 12 Sep 2018 07:51:47 +0000 (17:51 +1000)
committerMartin Schwenke <martins@samba.org>
Mon, 17 Sep 2018 20:58:20 +0000 (22:58 +0200)
commite789d0da57fc3fc6d22bfa00577a2e65034ca27a
treee447a9c0064cf3c7865f5b2769cc964a3f8d280f
parent5a6b139884f08ee2ee10f9d16fe56ad8fb5352a6
ctdb-cluster-mutex: Block signals around fork

If SIGTERM is received and the tevent signal handler setup in the
recovery daemon is still enabled then the signal is handled and a
corresponding event is queued.  The child never runs an event loop so
the signal is effectively ignored.

Resetting the SIGTERM handler isn't enough.  A signal can arrive
before that.

Block SIGTERM before forking and then immediately unblock it in the
parent.

In the child, unblock SIGTERM after the signal handler is reset.  An
explicit unblock is needed because according to sigprocmask(2) "the
signal mask is preserved across execve(2)".

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13617

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_cluster_mutex.c