11 unless ((`netstat -nap --inet` || "") =~ m!PID/Program!) {
12 plan skip_all => "netstat output not how expected; skipping test.\n";
18 my $TEST_IP = '127.0.1.1';
23 my $dir = File::Temp::tempdir( CLEANUP => 1 );
24 my $ms = eval { create_mogstored($TEST_IP, $dir, "--daemonize") };
25 unless (ok($ms, "started daemonized mogstored")) {
26 # Must wait a moment on startup
27 select undef, undef, undef, 0.5;
29 my $exist = eval { exist_pid() };
30 warn "exist = $exist\n";
32 warn "killing existing test mogstored pid of $exist\n";
35 die "wasn't able to start up.";
39 my $real_pid = exist_pid();
41 warn "real_pid = $real_pid\n";
44 my $sock = try(5, 0.5, sub { IO::Socket::INET->new(PeerAddr => "$TEST_IP:7501",
46 ok($sock, "got mgmt connection") or die;
49 print $sock "shutdown\n";
52 vec($rin,fileno($sock),1) = 1;
54 my $n = select($rout=$rin,undef,undef,2);
55 is($n, 1, "mgmt port readable");
59 die "killed pid of $real_pid\n";
64 while ($tries++ < 10 && ($alive = kill(0, $real_pid))) {
65 select undef, undef, undef, 0.4;
70 # dies when not able to find
72 my $netstat = `netstat -nap --inet`;
75 unless ($netstat =~ m!${ip}:750[10].+LISTEN\s+(\d+)/!) {
76 die "Couldn't find pid of daemonized process.\n";
82 my ($tries, $delay, $code) = @_;
84 while ($try++ < $tries) {
87 select undef, undef, undef, $delay;