v0.7: handle signals and adds pidfile
Fix signal handler so it uses the debug function