Skip to content

Conversation

DivInstance
Copy link

@DivInstance DivInstance commented Oct 2, 2025

Adds a terminate() method to the process class that sends SIGTERM instead of SIGKILL. This provides a more graceful way to stop processes, allowing them to clean up and exit properly. Resolves #2515.

Copy link
Member

@peace-maker peace-maker left a comment

Choose a reason for hiding this comment

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

Thank you! I've left some comments inline.

self.proc.terminate()
else:
# On Unix-like systems, send SIGTERM
os.kill(self.pid, signal.SIGTERM)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need this distinction since os.terminate is documented to send SIGTERM on posix-like systems. So we can just call terminate disregarding the host os

return

# Check if process is still running
if self.poll() is not None:
Copy link
Member

Choose a reason for hiding this comment

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

The poll check should be done afterwards to detect if the process exited immediately.

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.

Add a terminate method to the process object that invokes a sigterm, or alternitive.

2 participants