summaryrefslogtreecommitdiffstats
path: root/web/server/h2o/libh2o/misc/p5-Server-Starter/t/08-wait3.t
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--web/server/h2o/libh2o/misc/p5-Server-Starter/t/08-wait3.t39
1 files changed, 39 insertions, 0 deletions
diff --git a/web/server/h2o/libh2o/misc/p5-Server-Starter/t/08-wait3.t b/web/server/h2o/libh2o/misc/p5-Server-Starter/t/08-wait3.t
new file mode 100644
index 00000000..e13b6e8b
--- /dev/null
+++ b/web/server/h2o/libh2o/misc/p5-Server-Starter/t/08-wait3.t
@@ -0,0 +1,39 @@
+use strict;
+use warnings;
+use Test::More;
+use Server::Starter;
+
+my $gotsig = 0;
+Server::Starter::_set_sighandler('USR1', sub {
+ warn "got SIGUSR1";
+ ++$gotsig;
+});
+
+my $pid = fork;
+die "fork failed:$!"
+ unless defined $pid;
+if ($pid == 0) {
+ # child process, send signal twice
+ sleep 1;
+ kill 'USR1', getppid;
+ sleep 1;
+ kill 'USR1', getppid;
+ sleep 10;
+ die "child process not killed";
+}
+
+my @r = Server::Starter::_wait3(0);
+ok ! @r, "nonblocking wait returns without pid";
+
+for (my $i = 1; $i <= 2; ++$i) {
+ @r = Server::Starter::_wait3(1);
+ is $gotsig, $i, "woke up after signal (count: $i)";
+ ok ! @r, "child is alive";
+}
+
+kill 'KILL', $pid;
+@r = Server::Starter::_wait3(1);
+is $gotsig, 2, "did not receive signal";
+is $r[0], $pid, "child died";
+
+done_testing;