- ok(-f "$tmpdir/pid", 'pid file written');
- open my $fh, '<', "$tmpdir/pid" or die "open failed: $!";
- local $/ = "\n";
- my $rpid = <$fh>;
- chomp $rpid;
- like($rpid, qr/\A\d+\z/s, 'pid file looks like a pid');
- is(kill('TERM', $rpid), 1, 'signalled daemonized process');
- for (1..100) {
- kill(0, $rpid) or last;
- select undef, undef, undef, 0.02;
+ ok(-f $pid_file, "$w pid file written");
+ open my $fh, '<', "$tmpdir/pid" or die "open failed: $!";
+ my $rpid = do { local $/; <$fh> };
+ chomp $rpid;
+ like($rpid, qr/\A\d+\z/s, "$w pid file looks like a pid");
+ is(kill('TERM', $rpid), 1, "signaled daemonized $w process");
+ for (1..100) {
+ kill(0, $rpid) or last;
+ select undef, undef, undef, 0.02;
+ }
+ is(kill(0, $rpid), 0, "daemonized $w process exited");
+ ok(!-e $pid_file, "$w pid file unlinked at exit");