Skip to content

fix: kill subprocess - #8

Merged
Tohrusky merged 2 commits into
EutropicAI:mainfrom
TohruskyDev:main
Feb 16, 2026
Merged

fix: kill subprocess#8
Tohrusky merged 2 commits into
EutropicAI:mainfrom
TohruskyDev:main

Conversation

@Tohrusky

Copy link
Copy Markdown
Member

No description provided.

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @Tohrusky, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical issue where ZImage subprocesses might not be fully terminated, potentially leading to orphaned processes. It introduces a more comprehensive process killing mechanism by utilizing tree-kill to ensure all related processes are shut down. Additionally, it improves logging for better operational transparency and debugging, and refines state management logic in the renderer.

Highlights

  • Process Termination: Implemented robust process tree termination for ZImage processes using the tree-kill library, ensuring all child processes are properly shut down with SIGKILL.
  • Logging & Debugging: Enhanced logging for ZImage command execution and generation options, providing better visibility into the process and sending command output to the renderer.
  • State Management Refinement: Refined the order of state updates in the zimageStore to ensure isGenerating and logs are reset only when a valid model is selected for generation.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/main/zimage.ts
    • Imported the tree-kill library for advanced process management.
    • Modified runZImageCommand to log the full execution command and send it to the renderer via COMMAND_STDOUT.
    • Refactored killZImageProcess to use tree-kill with SIGKILL for killing the entire process tree, including checks for existing PID and promise-based execution with error handling.
    • Added a check to ensure zImageChild is cleared only if its PID matches the one being killed.
  • src/renderer/src/store/zimageStore.ts
    • Reordered the isGenerating and logs state resets to occur after the selectedModel validation.
    • Added logging of the full generation options object to the console and the internal logs before starting the generation process.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

The pull request successfully addresses the issue of orphaned subprocesses by implementing tree-kill to terminate the entire process tree. This is a necessary fix when using shell: true in Node.js. I have provided some feedback regarding naming consistency and log formatting to improve code quality and the readability of the output in the user interface.

Comment thread src/main/zimage.ts Outdated
Comment on lines +147 to +149
const current_start_args = `[Batch ${i + 1}/${count}] Executing ZImage: ${getCorePath()} ${args.join(' ')}`
console.log(current_start_args)
_event.sender.send(IpcChannelOn.COMMAND_STDOUT, current_start_args)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The variable name current_start_args uses snake_case, which is inconsistent with the camelCase convention used throughout the rest of the project (e.g., zImageChild, isBatchStopped). Additionally, adding a newline character (\n) to the end of the log string ensures that the command log is clearly separated from the subsequent process output in the renderer's log view.

Suggested change
const current_start_args = `[Batch ${i + 1}/${count}] Executing ZImage: ${getCorePath()} ${args.join(' ')}`
console.log(current_start_args)
_event.sender.send(IpcChannelOn.COMMAND_STDOUT, current_start_args)
const currentStartArgs = `[Batch ${i + 1}/${count}] Executing ZImage: ${getCorePath()} ${args.join(' ')}\n`
console.log(currentStartArgs)
_event.sender.send(IpcChannelOn.COMMAND_STDOUT, currentStartArgs)

Comment thread src/main/zimage.ts
console.log(`Killing ZImage process tree with PID: ${pid}`)

return new Promise<void>((resolve) => {
kill(pid, 'SIGKILL', (err) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using SIGKILL (9) is quite aggressive as it forces the process to terminate immediately without any opportunity for cleanup. It is generally recommended to use SIGTERM (the default for tree-kill) first. If SIGKILL is intentionally used to ensure compute-heavy tasks or GPU resources are released immediately, consider adding a brief comment to explain this choice.

Suggested change
kill(pid, 'SIGKILL', (err) => {
kill(pid, 'SIGTERM', (err) => {

@Tohrusky
Tohrusky merged commit 1a49e4b into EutropicAI:main Feb 16, 2026
6 checks passed
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.

1 participant