summaryrefslogtreecommitdiff
path: root/scripts/start-memcached
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/start-memcached')
-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);