Skip to content

auth: kill processes nicely - #17873

Open
miodvallat wants to merge 1 commit into
PowerDNS:masterfrom
miodvallat:killing_me_softly
Open

auth: kill processes nicely#17873
miodvallat wants to merge 1 commit into
PowerDNS:masterfrom
miodvallat:killing_me_softly

Conversation

@miodvallat

Copy link
Copy Markdown
Contributor

Short description

There used to be a school of thought advocating killing processes with SIGKILL, so that we can be sure the process gets away. Apparently whoever wrote that code in PowerDNS (in pre-subversion times, therefore before 2002) was a member of that school.

This PR replaces the use of SIGKILL by the use of SIGTERM first, waiting for up to two seconds for the process to have disappeared, and if it hasn't, reluctantly send a SIGKILL.

This can't be worse than the current behaviour.

Before, when issueing pdns_control cycle:

Aug 06 12:43:38 Our pdns instance (1733393) exited after signal 9
Aug 06 12:43:38 Respawning
Aug 06 12:43:39 Guardian is launching an instance

With this PR:

Aug 06 12:44:43 Our pdns instance (1733497) exited after signal 15
Aug 06 12:44:43 Respawning
Aug 06 12:44:44 Guardian is launching an instance

Checklist

I have:

  • read the CONTRIBUTING.md document
  • read and accepted the Developer Certificate of Origin document, including the AI Policy, and added a "Signed-off-by" to my commits
  • compiled this code
  • tested this code
  • included documentation (including possible behaviour changes)
  • documented the code
  • added or modified regression test(s)
  • added or modified unit test(s)

@coveralls

coveralls commented Aug 6, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 31098565664

Coverage increased (+5.6%) to 71.184%

Details

  • Coverage increased (+5.6%) from the base build.
  • Patch coverage: 15 uncovered changes across 1 file (0 of 15 lines covered, 0.0%).
  • 7158 coverage regressions across 80 files.

Uncovered Changes

File Changed Covered %
pdns/auth-main.cc 15 0 0.0%

Coverage Regressions

7158 previously-covered lines in 80 files lost coverage.

Top 10 Files by Coverage Loss Lines Losing Coverage Coverage
pdns/recursordist/pdns_recursor.cc 1107 46.21%
pdns/recursordist/lua-recursor4.cc 681 8.69%
pdns/recursordist/rec-main.cc 581 50.82%
pdns/recursordist/rec-tcp.cc 450 35.62%
pdns/recursordist/rec_channel_rec.cc 407 19.82%
pdns/recursordist/lwres.cc 353 38.44%
pdns/recursordist/rec-lua-conf.cc 352 19.84%
pdns/recursordist/syncres.cc 348 77.66%
pdns/recursordist/rec-rust-lib/cxxsupport.cc 343 58.03%
pdns/recursordist/rpzloader.cc 291 43.45%

Coverage Stats

Coverage Status
Relevant Lines: 173018
Covered Lines: 135044
Line Coverage: 78.05%
Relevant Branches: 82774
Covered Branches: 47039
Branch Coverage: 56.83%
Branches in Coverage %: Yes
Coverage Strength: 7196246.18 hits per line

💛 - Coveralls

Signed-off-by: Miod Vallat <miod.vallat@powerdns.com>
Comment thread pdns/auth-main.cc
// Give a few seconds (well, 2) to the process to disappear
for (unsigned int cycles = 2 * 10; cycles != 0; --cycles) {
Utility::usleep(100UL * 1000UL);
if (kill(pid, 0) != 0 && errno == ESRCH) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pdns_control cycle gets the desired ESRCH in 5 to 8 rounds here. pdns_control quit always ends up sending SIGKILL. I am not sure why this is.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anything particular in your configuration, which could cause the server to take time to exit?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants