added signal handling without races