Skip to content

Fix process group termination: always send SIGKILL after SIGTERM#151

Open
TravisRiveraPetit wants to merge 2 commits intomainfrom
fix-kill-process-group
Open

Fix process group termination: always send SIGKILL after SIGTERM#151
TravisRiveraPetit wants to merge 2 commits intomainfrom
fix-kill-process-group

Conversation

@TravisRiveraPetit
Copy link
Copy Markdown

Fixes an issue in Call._terminate_process_group where SIGKILL was only sent if the parent process was still alive.

os.killpg(os.getpgid(self.process.pid), signal.SIGKILL)

with contextlib.suppress(OSError, ProcessLookupError):
os.killpg(pgid, signal.SIGKILL)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the rationale for this change? I don't think it's good style to kill a process that we know has terminated. Is poll not reliable? If the process has terminated, it will be in zombie state here. Better to have it finish normally than kill it, I would say, if it has terminated in the one-second grace period.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The problem is that we are currently using poll() on the leader process as a proxy for whether the whole process group has terminated.

Before, if the leader spawned child processes, it could happen that the leader exited after SIGTERM while some children were still running. In that case, poll() would return the leader’s exit code rather than None.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants