Skip to content

Comments

Добавлен параметр завершения дочерних процессов в метод Завершить()#1660

Open
yukon39 wants to merge 1 commit intoEvilBeaver:developfrom
yukon39:issue-1659
Open

Добавлен параметр завершения дочерних процессов в метод Завершить()#1660
yukon39 wants to merge 1 commit intoEvilBeaver:developfrom
yukon39:issue-1659

Conversation

@yukon39
Copy link
Contributor

@yukon39 yukon39 commented Feb 24, 2026

Описание изменений:

  • Расширен метод ProcessContext.Stop/Завершить: добавлен опциональный параметр entireProcessTree для завершения дерева процесса.
  • Для обратной совместимости сохранено поведение по умолчанию: Stop() завершает только текущий процесс (entireProcessTree = false).
  • Вызов прокинут в .NET через Process.Kill(entireProcessTree).

closes #1659

Summary by CodeRabbit

  • New Features
    • Process termination now accepts an optional flag to control stopping the entire process tree; default behavior remains stopping only the main process.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7861ac6 and 3a6e470.

📒 Files selected for processing (1)
  • src/OneScript.StandardLibrary/Processes/ProcessContext.cs

📝 Walkthrough

Walkthrough

The Stop() method in ProcessContext now accepts an optional boolean parameter entireProcessTree (default false) and forwards it to the underlying Process.Kill(entireProcessTree) call. XML documentation for the new parameter and exceptions was added.

Changes

Cohort / File(s) Summary
Process Context Enhancement
src/OneScript.StandardLibrary/Processes/ProcessContext.cs
Changed public void Stop()public void Stop(bool entireProcessTree = false); updated internal call to _p.Kill(entireProcessTree) and added XML documentation for the new parameter and exceptions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related issues

  • Issue #1659 — adds optional boolean parameter to control termination of child processes from ProcessContext.Stop().

Poem

🐰 I nudge a process, whisper "cease",
Or choose to end its branching lease,
A tiny flag, a safer hop,
The tree falls quiet — then I stop ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding a parameter to the Stop/Завершить() method for terminating child processes.
Linked Issues check ✅ Passed The pull request fully addresses issue #1659 by adding an optional boolean parameter (entireProcessTree) to the Stop() method to control child process termination.
Out of Scope Changes check ✅ Passed All changes are directly related to the stated objective of adding child process termination capability; no out-of-scope modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@yukon39 yukon39 changed the title Добавлено параметр завершения дочерних процессов в метод Завершить() Добавлен параметр завершения дочерних процессов в метод Завершить() Feb 24, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/OneScript.StandardLibrary/Processes/ProcessContext.cs`:
- Around line 199-207: Update the XML documentation for ProcessContext.Stop (the
method wrapping _p.Kill) to explicitly state that calling Stop(true) /
Завершить(Истина) kills the root process but WaitForExit and the HasExited
property do not wait for or reflect termination of descendant processes, so
callers using ОжидатьЗавершения() / WaitForExit after Stop(true) may still
observe running child processes and should handle descendant termination
separately; include this note in the <summary> or as an additional <remarks>
sentence so it's clearly visible in generated docs.
- Around line 199-207: The Stop method calls _p.Kill(entireProcessTree) which
can throw AggregateException when Kill(true) cannot terminate some descendant
processes (e.g., due to permissions); update Stop to catch AggregateException
from the call to Kill and rethrow a clearer exception (e.g., throw new
InvalidOperationException("Failed to terminate one or more child processes.",
ex)) preserving the original AggregateException as InnerException, and also add
an XML <exception> entry to Stop's doc comment that documents this
AggregateException/InvalidOperationException scenario when entireProcessTree is
true; reference the Stop method and the call to Kill(bool) when making the
changes.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8207c80 and 7861ac6.

📒 Files selected for processing (1)
  • src/OneScript.StandardLibrary/Processes/ProcessContext.cs

Comment on lines 199 to 207
/// <summary>
/// Завершить процесс и, опционально, все его дочерние процессы.
/// </summary>
/// <param name="entireProcessTree">Булево. Завершить все дочерние процессы.</param>
[ContextMethod("Завершить", "Stop")]
public void Stop(bool entireProcessTree = false)
{
_p.Kill();
_p.Kill(entireProcessTree);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

WaitForExit/HasExited do not track descendant termination after Kill(true)

The WaitForExit method and the HasExited property do not reflect the status of descendant processes; when Kill(entireProcessTree: true) is used, they will indicate completion after the root process exits, even if all descendants have not yet exited.

This is a subtle behavioral difference worth noting in the method's XML documentation so that callers who call ОжидатьЗавершения() / WaitForExit after Завершить(Истина) are not surprised.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/OneScript.StandardLibrary/Processes/ProcessContext.cs` around lines 199 -
207, Update the XML documentation for ProcessContext.Stop (the method wrapping
_p.Kill) to explicitly state that calling Stop(true) / Завершить(Истина) kills
the root process but WaitForExit and the HasExited property do not wait for or
reflect termination of descendant processes, so callers using
ОжидатьЗавершения() / WaitForExit after Stop(true) may still observe running
child processes and should handle descendant termination separately; include
this note in the <summary> or as an additional <remarks> sentence so it's
clearly visible in generated docs.

⚠️ Potential issue | 🟡 Minor

AggregateException from Kill(true) is unhandled and undocumented

Kill(bool) can throw an AggregateException when not all processes in the associated process's descendant tree could be terminated. This occurs when Kill(true) tries to terminate child processes but lacks permissions for some of them — for example, processes owned by different users.

The XML <summary> and <param> doc do not mention this, so script callers have no warning. Consider either wrapping it or at minimum adding a <exception> doc tag.

📝 Suggested doc addition
 /// <summary>
 /// Завершить процесс и, опционально, все его дочерние процессы.
 /// </summary>
 /// <param name="entireProcessTree">Булево. Завершить все дочерние процессы.</param>
+/// <exception cref="AggregateException">Не все дочерние процессы удалось завершить (только при entireProcessTree = true).</exception>
 [ContextMethod("Завершить", "Stop")]
 public void Stop(bool entireProcessTree = false)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/// <summary>
/// Завершить процесс и, опционально, все его дочерние процессы.
/// </summary>
/// <param name="entireProcessTree">Булево. Завершить все дочерние процессы.</param>
[ContextMethod("Завершить", "Stop")]
public void Stop(bool entireProcessTree = false)
{
_p.Kill();
_p.Kill(entireProcessTree);
}
/// <summary>
/// Завершить процесс и, опционально, все его дочерние процессы.
/// </summary>
/// <param name="entireProcessTree">Булево. Завершить все дочерние процессы.</param>
/// <exception cref="AggregateException">Не все дочерние процессы удалось завершить (только при entireProcessTree = true).</exception>
[ContextMethod("Завершить", "Stop")]
public void Stop(bool entireProcessTree = false)
{
_p.Kill(entireProcessTree);
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/OneScript.StandardLibrary/Processes/ProcessContext.cs` around lines 199 -
207, The Stop method calls _p.Kill(entireProcessTree) which can throw
AggregateException when Kill(true) cannot terminate some descendant processes
(e.g., due to permissions); update Stop to catch AggregateException from the
call to Kill and rethrow a clearer exception (e.g., throw new
InvalidOperationException("Failed to terminate one or more child processes.",
ex)) preserving the original AggregateException as InnerException, and also add
an XML <exception> entry to Stop's doc comment that documents this
AggregateException/InvalidOperationException scenario when entireProcessTree is
true; reference the Stop method and the call to Kill(bool) when making the
changes.

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