reload-uses-sigkill-as-last-measure.phpt 1.3 KB

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