X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Ftincd.c;h=0da27a38d49f43b6403649b89ceeeaffc2fc34e1;hp=124276f1d0a0b41d1342f58b48ce72ab9f6458a9;hb=f2076e3e7031ac8ad87eb6aab0cea40f379dd0c6;hpb=98de35c742498878a27fb29becd3b7154525a60f;ds=sidebyside diff --git a/src/tincd.c b/src/tincd.c index 124276f1..0da27a38 100644 --- a/src/tincd.c +++ b/src/tincd.c @@ -181,10 +181,11 @@ int detach(void) close(fd); } - kill(ppid, SIGTERM); - if(setsid() < 0) return -1; + + kill(ppid, SIGTERM); + chdir("/"); /* avoid keeping a mointpoint busy */ openlog(identname, LOG_CONS | LOG_PID, LOG_DAEMON); @@ -343,7 +344,10 @@ main(int argc, char **argv, char **envp) setup_signals(); if(detach()) - cleanup_and_exit(1); + { + kill(ppid, SIGTERM); + exit(0); + } if(security_init()) return 1; @@ -432,10 +436,10 @@ RETSIGTYPE sighuh(int a) { if(cp_file) - syslog(LOG_NOTICE, "Got unexpected signal after %s line %d.", - cp_file, cp_line); + syslog(LOG_NOTICE, "Got unexpected signal (%d) after %s line %d.", + a, cp_file, cp_line); else - syslog(LOG_NOTICE, "Got unexpected signal."); + syslog(LOG_NOTICE, "Got unexpected signal (%d).", a); } void