summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Linehan <linehan@myhost.(none)>2012-06-13 19:51:44 -0400
committerJason Linehan <linehan@myhost.(none)>2012-06-13 19:51:44 -0400
commit19d5350c854a620294aa5ede38d76438d4f6fd47 (patch)
tree3a69520fa8f3aa704cdab8f54e2e5605e24bdcd8
parent0722a90cf24759f9b8729999db1f2be536df34fd (diff)
downloadcloth-19d5350c854a620294aa5ede38d76438d4f6fd47.tar.gz
cloth-19d5350c854a620294aa5ede38d76438d4f6fd47.tar.bz2
cloth-19d5350c854a620294aa5ede38d76438d4f6fd47.zip
Daemonization stuff out of Stevens. Tweaked README
-rw-r--r--README2
-rw-r--r--cloth.c9
2 files changed, 9 insertions, 2 deletions
diff --git a/README b/README
index 82ad9af..dfc24e8 100644
--- a/README
+++ b/README
@@ -15,5 +15,5 @@ If you don't have any content or just want to test it out,
try providing the included www folder as a the WWW_ROOT path.
NOTE: the command line arguments must NOT be relative paths,
- i.e., no '~/foo' or '../../baz'
+ i.e., no './foo' or '../bar'
diff --git a/cloth.c b/cloth.c
index aba3caa..a779ee1 100644
--- a/cloth.c
+++ b/cloth.c
@@ -8,6 +8,7 @@
#include <time.h>
#include <sys/types.h>
#include <sys/socket.h>
+#include <sys/param.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@@ -290,13 +291,19 @@ void cloth(int port)
int fd_listen;
int hit;
int pid;
+ int i;
/**********************************************
* Prepare the process to run as a daemon *
**********************************************/
+ for (i=0; i<NOFILE; i++) /* Close files inherited from parent */
+ close(i);
+
+ umask(0); /* Reset file access creation mask */
signal(SIGCLD, SIG_IGN); /* Ignore child death */
signal(SIGHUP, SIG_IGN); /* Ignore terminal hangups */
- setpgrp(); /* Break away from process group */
+ setpgrp(); /* Create new process group */
+
log(INFO, "cloth is starting up...", "", getpid());