Kill the parent after any error conditions in detach().
This commit is contained in:
parent
98de35c742
commit
f2076e3e70
1 changed files with 10 additions and 6 deletions
16
src/tincd.c
16
src/tincd.c
|
@ -181,10 +181,11 @@ int detach(void)
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
kill(ppid, SIGTERM);
|
|
||||||
|
|
||||||
if(setsid() < 0)
|
if(setsid() < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
kill(ppid, SIGTERM);
|
||||||
|
|
||||||
chdir("/"); /* avoid keeping a mointpoint busy */
|
chdir("/"); /* avoid keeping a mointpoint busy */
|
||||||
|
|
||||||
openlog(identname, LOG_CONS | LOG_PID, LOG_DAEMON);
|
openlog(identname, LOG_CONS | LOG_PID, LOG_DAEMON);
|
||||||
|
@ -343,7 +344,10 @@ main(int argc, char **argv, char **envp)
|
||||||
setup_signals();
|
setup_signals();
|
||||||
|
|
||||||
if(detach())
|
if(detach())
|
||||||
cleanup_and_exit(1);
|
{
|
||||||
|
kill(ppid, SIGTERM);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
if(security_init())
|
if(security_init())
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -432,10 +436,10 @@ RETSIGTYPE
|
||||||
sighuh(int a)
|
sighuh(int a)
|
||||||
{
|
{
|
||||||
if(cp_file)
|
if(cp_file)
|
||||||
syslog(LOG_NOTICE, "Got unexpected signal after %s line %d.",
|
syslog(LOG_NOTICE, "Got unexpected signal (%d) after %s line %d.",
|
||||||
cp_file, cp_line);
|
a, cp_file, cp_line);
|
||||||
else
|
else
|
||||||
syslog(LOG_NOTICE, "Got unexpected signal.");
|
syslog(LOG_NOTICE, "Got unexpected signal (%d).", a);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Add table
Reference in a new issue