aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bachelier <laurent@bachelier.name>2010-12-23 09:29:32 +0100
committerLaurent Bachelier <laurent@bachelier.name>2010-12-23 19:34:48 +0100
commitc8cc67580d7da3e3ad7376280890b83c903e03c7 (patch)
tree93724f3a9d49c9ef0cf8a05104fe4b6243886289
parentCreate "fork" option (diff)
downloadsymfttpd-c8cc67580d7da3e3ad7376280890b83c903e03c7.tar.xz
Implements the forking logic
-rwxr-xr-xspawn32
1 files changed, 29 insertions, 3 deletions
diff --git a/spawn b/spawn
index 52d3d12..d3a525c 100755
--- a/spawn
+++ b/spawn
@@ -108,6 +108,32 @@ foreach ($apps as $app)
log_message("\nPress Ctrl+C to stop serving.");
flush();
-passthru($options['lighttpd_cmd'].' -D -f '.escapeshellarg($config_file));
-
-log_message('Terminated');
+if (!$options['fork'])
+{
+ passthru($options['lighttpd_cmd'].' -D -f '.escapeshellarg($config_file));
+ log_message('Terminated');
+}
+else
+{
+ $pid = pcntl_fork();
+ if ($pid)
+ {
+ // Parent process
+ while (true)
+ {
+ sleep(1);
+ // TODO will do magical and revolutionary stuff
+ }
+ }
+ elseif ($pid == 0)
+ {
+ // Child process
+ passthru($options['lighttpd_cmd'].' -D -f '.escapeshellarg($config_file));
+ log_message('Terminated');
+ }
+ else
+ {
+ log_message('Unable to fork!');
+ exit(1);
+ }
+}