Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/azatoth/minidlna.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Maggard <jmaggard@users.sourceforce.net>2011-09-03 05:32:56 +0400
committerJustin Maggard <jmaggard@users.sourceforce.net>2011-09-03 05:32:56 +0400
commit167ea318885a8c1ec20fc0ea3ded6197ee49ed7e (patch)
treee61e92761c18ba29ea479d47732ec0e783dde52b
parent5ca57319c7c29ff8891efe06605065776dedb62b (diff)
* Simplify daemonize ifdefs.
-rw-r--r--daemonize.c18
-rw-r--r--daemonize.h2
-rw-r--r--minidlna.c7
3 files changed, 11 insertions, 16 deletions
diff --git a/daemonize.c b/daemonize.c
index b1bfe9c..9a10276 100644
--- a/daemonize.c
+++ b/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)
diff --git a/daemonize.h b/daemonize.h
index ee763bd..7a05d6c 100644
--- a/daemonize.h
+++ b/daemonize.h
@@ -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 */
diff --git a/minidlna.c b/minidlna.c
index 1ce0d52..4fa5f2e 100644
--- a/minidlna.c
+++ b/minidlna.c
@@ -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