See nexedi/nxdtest@b0cf277d for details and for why signal handling is implemented like this.
/cc @lpgeneau