HEX
Server: Apache
System: Linux msm5694.mjhst.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: camjab_ssh (1000)
PHP: 5.3.29
Disabled: NONE
Upload Files
File: //usr/src/memcached-1.4.13/t/daemonize.t
#!/usr/bin/perl

use strict;
use Test::More tests => 7;
use FindBin qw($Bin);
use lib "$Bin/lib";
use MemcachedTest;

use File::Temp qw(tempfile);

my (undef, $tmpfn) = tempfile();

my $server = new_memcached("-d -P $tmpfn");
my $sock = $server->sock;
sleep 0.5;

ok(-e $tmpfn, "pid file exists");
ok(-s $tmpfn, "pid file has length");

open (my $fh, $tmpfn) or die;
my $readpid = do { local $/; <$fh>; };
chomp $readpid;
close ($fh);

ok(kill(0, $readpid), "process is still running");

my $stats = mem_stats($sock);
is($stats->{pid}, $readpid, "memcached reports same pid as file");

ok($server->new_sock, "opened new socket");
ok(kill(9, $readpid), "sent KILL signal");
sleep 0.5;
ok(! $server->new_sock, "failed to open new socket");