mirror of
https://git.code.sf.net/p/minidlna/git
synced 2025-04-20 12:10:22 +00:00
* Simplify daemonize ifdefs.
This commit is contained in:
18
daemonize.c
18
daemonize.c
@ -41,12 +41,12 @@
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
|
||||
#ifndef USE_DAEMON
|
||||
|
||||
int
|
||||
daemonize(void)
|
||||
{
|
||||
int pid, i;
|
||||
int pid;
|
||||
#ifndef USE_DAEMON
|
||||
int i;
|
||||
|
||||
switch(fork())
|
||||
{
|
||||
@ -72,16 +72,20 @@ daemonize(void)
|
||||
dup(i); /* stderr */
|
||||
|
||||
umask(027);
|
||||
chdir("/"); /* chdir to /tmp ? */
|
||||
|
||||
return pid;
|
||||
chdir("/");
|
||||
|
||||
break;
|
||||
/* parent process */
|
||||
default:
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
#else
|
||||
if( daemon(0, 0) < 0 )
|
||||
perror("daemon()");
|
||||
pid = getpid();
|
||||
#endif
|
||||
return pid;
|
||||
}
|
||||
|
||||
int
|
||||
writepidfile(const char * fname, int pid)
|
||||
|
@ -31,13 +31,11 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifndef USE_DAEMON
|
||||
/* daemonize()
|
||||
* "fork" to background, detach from terminal, etc...
|
||||
* returns: pid of the daemon, exits upon failure */
|
||||
int
|
||||
daemonize(void);
|
||||
#endif
|
||||
|
||||
/* writepidfile()
|
||||
* write the pid to a file */
|
||||
|
@ -789,14 +789,7 @@ init(int argc, char * * argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef USE_DAEMON
|
||||
if(daemon(0, 0)<0) {
|
||||
perror("daemon()");
|
||||
}
|
||||
pid = getpid();
|
||||
#else
|
||||
pid = daemonize();
|
||||
#endif
|
||||
#ifdef READYNAS
|
||||
log_init("/var/log/upnp-av.log", "general,artwork,database,inotify,scanner,metadata,http,ssdp,tivo=warn");
|
||||
#else
|
||||
|
Reference in New Issue
Block a user