Block signals sooner to avoid race conditions
Fix format string

Thanks Jianhai Luan.