minissdpd: daemonize after init
In order to fail launch and return an error to the parent process if the init fails. See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=644509
This commit is contained in:
parent
5e69a32343
commit
7846aaa4c2
|
@ -3,6 +3,7 @@ $Id: Changelog.txt,v 1.20 2011/10/07 09:21:19 nanard Exp $
|
|||
2011/10/07:
|
||||
unlink unix socket before binding.
|
||||
set SO_REUSEADDR on SSDP socket.
|
||||
daemonize after init
|
||||
|
||||
VERSION 1.1:
|
||||
|
||||
|
|
|
@ -819,18 +819,6 @@ int main(int argc, char * * argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* daemonize or in any case get pid ! */
|
||||
if(debug_flag)
|
||||
pid = getpid();
|
||||
else {
|
||||
#ifdef USE_DAEMON
|
||||
if(daemon(0, 0) < 0)
|
||||
perror("daemon()");
|
||||
pid = getpid();
|
||||
#else
|
||||
pid = daemonize();
|
||||
#endif
|
||||
}
|
||||
/* open log */
|
||||
openlog("minissdpd",
|
||||
LOG_CONS|LOG_PID|(debug_flag?LOG_PERROR:0),
|
||||
|
@ -844,8 +832,6 @@ int main(int argc, char * * argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
writepidfile(pidfilename, pid);
|
||||
|
||||
/* set signal handlers */
|
||||
memset(&sa, 0, sizeof(struct sigaction));
|
||||
sa.sa_handler = sigterm;
|
||||
|
@ -923,6 +909,21 @@ int main(int argc, char * * argv)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* daemonize or in any case get pid ! */
|
||||
if(debug_flag)
|
||||
pid = getpid();
|
||||
else {
|
||||
#ifdef USE_DAEMON
|
||||
if(daemon(0, 0) < 0)
|
||||
perror("daemon()");
|
||||
pid = getpid();
|
||||
#else
|
||||
pid = daemonize();
|
||||
#endif
|
||||
}
|
||||
|
||||
writepidfile(pidfilename, pid);
|
||||
|
||||
/* Main loop */
|
||||
while(!quitting)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue