summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kneschke <jan@kneschke.de>2005-10-11 09:29:30 +0000
committerJan Kneschke <jan@kneschke.de>2005-10-11 09:29:30 +0000
commit85617fc33778117f1ddfe2a8a36370360fe83ce8 (patch)
tree414274b34a6e01b7c550f1861351c710245fb536
parentd24262a03c01f618b8f37d1f9670dec325135da4 (diff)
downloadlighttpd-git-85617fc33778117f1ddfe2a8a36370360fe83ce8.tar.gz
add no-fork option for daemontools (fixed #295)
git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@787 152afb58-edef-0310-8abb-c4023f1b3aa9
-rw-r--r--src/spawn-fcgi.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/spawn-fcgi.c b/src/spawn-fcgi.c
index 52909371..99fc31a2 100644
--- a/src/spawn-fcgi.c
+++ b/src/spawn-fcgi.c
@@ -41,7 +41,7 @@ typedef int socklen_t;
#endif
#ifdef HAVE_SYS_UN_H
-int fcgi_spawn_connection(char *appPath, unsigned short port, const char *unixsocket, int child_count, int pid_fd) {
+int fcgi_spawn_connection(char *appPath, unsigned short port, const char *unixsocket, int child_count, int pid_fd, int nofork) {
int fcgi_fd;
int socket_type, status;
struct timeval tv = { 0, 100 * 1000 };
@@ -127,8 +127,14 @@ int fcgi_spawn_connection(char *appPath, unsigned short port, const char *unixso
__FILE__, __LINE__);
return -1;
}
+
+ if (!nofork) {
+ child = fork();
+ } else {
+ child = 0;
+ }
- switch ((child = fork())) {
+ switch (child) {
case 0: {
char cgi_childs[64];
char *b;
@@ -241,6 +247,7 @@ void show_help () {
" -s <path> bind to unix-domain socket\n" \
" -C <childs> (PHP only) numbers of childs to spawn (default 5)\n" \
" -P <path> name of PID-file for spawed process\n" \
+" -n no fork (for daemontools)\n" \
" -v show version\n" \
" -h show this help\n" \
"(root only)\n" \
@@ -259,10 +266,11 @@ int main(int argc, char **argv) {
int child_count = 5;
int i_am_root, o;
int pid_fd = -1;
+ int nofork = 0;
i_am_root = (getuid() == 0);
- while(-1 != (o = getopt(argc, argv, "c:f:g:hp:u:vC:s:P:"))) {
+ while(-1 != (o = getopt(argc, argv, "c:f:g:hnp:u:vC:s:P:"))) {
switch(o) {
case 'f': fcgi_app = optarg; break;
case 'p': port = strtol(optarg, NULL, 10);/* port */ break;
@@ -271,6 +279,7 @@ int main(int argc, char **argv) {
case 'c': if (i_am_root) { changeroot = optarg; }/* chroot() */ break;
case 'u': if (i_am_root) { username = optarg; } /* set user */ break;
case 'g': if (i_am_root) { groupname = optarg; } /* set group */ break;
+ case 'n': nofork = 1; break;
case 'P': pid_file = optarg; /* PID file */ break;
case 'v': show_version(); return 0;
case 'h': show_help(); return 0;
@@ -413,7 +422,7 @@ int main(int argc, char **argv) {
if (username) setuid(pwd->pw_uid);
}
- return fcgi_spawn_connection(fcgi_app, port, unixsocket, child_count, pid_fd);
+ return fcgi_spawn_connection(fcgi_app, port, unixsocket, child_count, pid_fd, nofork);
}
#else
int main() {