MCPcopy
hub / github.com/saltstack/salt / _hard_kill

Function _hard_kill

tests/conftest.py:1636–1655  ·  view source on GitHub ↗

Unconditional kernel-level kill — bypasses GIL / Python locks.

()

Source from the content-addressed store, hash-verified

1634 dump_path = pathlib.Path("/tmp/exit-watchdog-traceback.log")
1635
1636 def _hard_kill():
1637 """Unconditional kernel-level kill — bypasses GIL / Python locks."""
1638 time.sleep(grace + hard_kill_extra)
1639 try:
1640 # pylint: disable=resource-leakage
1641 # We deliberately use the stdlib ``open`` here, not
1642 # ``salt.utils.files.fopen``: the watchdog must avoid
1643 # touching salt code paths that may themselves be
1644 # implicated in the hang we're trying to escape.
1645 with open(str(dump_path) + ".sigkill", "w", encoding="utf-8") as fp:
1646 fp.write(
1647 f"SALT EXIT WATCHDOG: SIGKILL backstop fired after "
1648 f"{grace + hard_kill_extra}s. Watchdog dump either hung "
1649 "or never reached os._exit. Process is being killed by "
1650 "the kernel; check exit-watchdog-traceback.log for the "
1651 "partial dump captured before SIGKILL.\n"
1652 )
1653 except OSError:
1654 pass
1655 os.kill(os.getpid(), signal.SIGKILL)
1656
1657 def _watchdog():
1658 time.sleep(grace)

Callers

nothing calls this directly

Calls 4

killMethod · 0.80
openFunction · 0.50
sleepMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected