summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorClint Byrum <superamazingdude@gmail.com>2011-08-07 23:02:31 -0700
committerdormando <dormando@rydia.net>2011-08-10 08:44:52 -0700
commite04ca9b70bf1f56093143f7b825ddec078a6fd42 (patch)
treea67d9cf41c59539f2c7b424ce5390a9ef0254d12 /scripts
parent2928a78562c91d2706b35826eea77f3bf0366035 (diff)
downloadmemcached-e04ca9b70bf1f56093143f7b825ddec078a6fd42.tar.gz
Properly daemonize memcached for debian
The debianish start script routes the STDERR/STDOUT to make "logfiles", but in doing so doesn't break free of the launching session. Patch fixes that.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/start-memcached8
1 files changed, 8 insertions, 0 deletions
diff --git a/scripts/start-memcached b/scripts/start-memcached
index e33b95c..aa9dabe 100755
--- a/scripts/start-memcached
+++ b/scripts/start-memcached
@@ -7,6 +7,7 @@
# Anyone may use this little script under the same terms as
# memcached itself.
+use POSIX qw(setsid);
use strict;
if($> != 0 and $< != 0)
@@ -105,7 +106,14 @@ my $pid = fork();
if($pid == 0)
{
+ # setsid makes us the session leader
+ setsid();
reopen_logfile($fd_reopened);
+ # must fork again now that tty is closed
+ $pid = fork();
+ if ($pid) {
+ exit(0);
+ }
exec "$memcached $params";
exit(0);