1--TEST--
2FPM: If SIGQUIT and SIGTERM during reloading fail, SIGKILL should be sent
3--EXTENSIONS--
4pcntl
5--SKIPIF--
6<?php
7include "skipif.inc";
8if (!function_exists('pcntl_sigprocmask')) die('skip Requires pcntl_sigprocmask()');
9if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request');
10?>
11--FILE--
12<?php
13
14require_once "tester.inc";
15
16$cfg = <<<EOT
17[global]
18error_log = {{FILE:LOG}}
19pid = {{FILE:PID}}
20process_control_timeout=1
21[unconfined]
22listen = {{ADDR}}
23ping.path = /ping
24ping.response = pong
25pm = dynamic
26pm.max_children = 5
27pm.start_servers = 1
28pm.min_spare_servers = 1
29pm.max_spare_servers = 1
30EOT;
31
32$code = <<<EOT
33<?php
34pcntl_sigprocmask(SIG_BLOCK, [SIGQUIT, SIGTERM]);
35EOT;
36
37$tester = new FPM\Tester($cfg, $code);
38$tester->start(extensions: ['pcntl']);
39$tester->expectLogStartNotices();
40$tester->request()->expectEmptyBody();
41$tester->signal('USR2');
42$tester->expectLogNotice('Reloading in progress ...');
43$tester->expectLogNotice('reloading: .*');
44// The timeout needs to elapse twice until the process will be killed,
45// so we have to wait at least two seconds.
46sleep(2);
47$tester->expectLogNotice('using inherited socket fd=\d+, "127.0.0.1:\d+"');
48$tester->expectLogStartNotices();
49$tester->ping('{{ADDR}}');
50$tester->terminate();
51$tester->expectLogTerminatingNotices();
52$tester->close();
53
54?>
55Done
56--EXPECT--
57Done
58--CLEAN--
59<?php
60require_once "tester.inc";
61FPM\Tester::clean();
62?>
63