You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "jjj-n (via GitHub)" <gi...@apache.org> on 2026/08/29 11:56:26 UTC

[PR] fix(eval): make process termination work on Windows [maka]

jjj-n opened a new pull request, #4175:
URL: https://github.com/apache/maka/pull/4175

   ## Summary
   
   - Add a shared Eval process-termination helper with native graceful Windows stops and `taskkill.exe` tree escalation for forced cleanup.
   - Use the helper for harness trials, external subject wrappers, and preflight timeout/cancellation paths.
   
   Fixes #3892.
   
   ## Verification
   
   - `npm run lint` passed.
   - `npm run format:check` passed.
   - `npm --workspace @maka/eval run typecheck` passed.
   - `npm --workspace @maka/eval run build` passed.
   - `npx knip --workspace apps/desktop` passed.
   - `npx knip --workspace packages/ui` passed.
   - `node --test packages/eval/dist/__tests__/process-termination.test.js packages/eval/dist/__tests__/install-preflight.test.js` passed: 10 passed, 3 skipped because this Windows environment does not grant symlink/permission prerequisites.
   - Root `npm run typecheck` is blocked by existing `@maka/ui` errors for `settledText`, `autoScroll`, and `trailingAction`; Eval and its dependencies typecheck successfully.
   - Root `npm run build` reaches the same existing `@maka/ui` type errors after building Eval and its dependencies.
   - The full Eval suite was not reported as passing because this Windows environment exposes existing POSIX/shebang, symlink, and path assumptions in unrelated tests.
   
   ## AI use
   
   - [ ] No generative tool made a substantive contribution
   - [x] Generative tooling made a substantive contribution
   
   Tool(s) and scope: Codex implemented the process-termination helper, call-site updates, regression tests, and verification. The human contributor of record reviews the implementation for correctness and licensing.
   
   ## Checklist
   
   - [x] Tests cover the change and fail without it
   - [x] Lint, format, typecheck and the affected suites pass locally
   
   Does this PR entail a change in behavior?
   
   - [x] Yes - described under Summary above
   - [ ] No


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(eval): make process termination work on Windows [maka]

Posted by "hqhq1025 (via GitHub)" <gi...@apache.org>.
hqhq1025 commented on code in PR #4175:
URL: https://github.com/apache/maka/pull/4175#discussion_r3889123194


##########
packages/eval/src/process-termination.ts:
##########
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { spawn, type ChildProcess } from 'node:child_process';
+
+export type ProcessTerminationSignal = 'SIGINT' | 'SIGTERM' | 'SIGKILL';
+
+const WINDOWS_TASKKILL_TIMEOUT_MS = 2_000;
+
+export interface ProcessTerminationOptions {
+  readonly platform?: NodeJS.Platform;
+  readonly runTaskkill?: (pid: number) => Promise<boolean>;
+}
+
+/**
+ * Terminates a child using the platform's process lifecycle semantics.
+ * Windows does not implement POSIX signals: a graceful stop uses Node's
+ * default child termination, while a forced stop must include descendants.
+ */
+export function terminateProcess(
+  child: ChildProcess | undefined,
+  signal: ProcessTerminationSignal,
+  options: ProcessTerminationOptions = {},
+): Promise<boolean> {
+  if (!child || child.exitCode !== null || child.signalCode !== null) return Promise.resolve(false);
+
+  const platform = options.platform ?? process.platform;
+  if (platform === 'win32') {
+    if (signal !== 'SIGKILL') return killChild(child);

Review Comment:
   [P1] The normal Windows cleanup path never reaches the tree kill. `waitForTrial()` first calls this helper with `SIGTERM`, and this branch calls only `child.kill()`; the new unit test explicitly asserts that `runTaskkill` is not invoked. On Windows, Node treats the default/SIGTERM child kill as an abrupt termination of the target process, so the supervisor exits promptly and `waitForTrial()` returns from its `terminated` branch before the later `SIGKILL` escalation can call `taskkill /T /F`. Any worker already spawned by the supervisor can therefore survive cancellation or timeout. A direct probe of this control flow produced `supervisorExited=true`, `taskkills=0`, `workerAlive=true`. Please make the Windows first-stage cleanup tree-aware (or request graceful teardown over an IPC channel and always retain a tree-kill fallback), and add an integration regression where the supervisor exits but a descendant stays alive.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(eval): make process termination work on Windows [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han merged PR #4175:
URL: https://github.com/apache/maka/pull/4175


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(eval): make process termination work on Windows [maka]

Posted by "jjj-n (via GitHub)" <gi...@apache.org>.
jjj-n commented on code in PR #4175:
URL: https://github.com/apache/maka/pull/4175#discussion_r3889280067


##########
packages/eval/src/process-termination.ts:
##########
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { spawn, type ChildProcess } from 'node:child_process';
+
+export type ProcessTerminationSignal = 'SIGINT' | 'SIGTERM' | 'SIGKILL';
+
+const WINDOWS_TASKKILL_TIMEOUT_MS = 2_000;
+
+export interface ProcessTerminationOptions {
+  readonly platform?: NodeJS.Platform;
+  readonly runTaskkill?: (pid: number) => Promise<boolean>;
+}
+
+/**
+ * Terminates a child using the platform's process lifecycle semantics.
+ * Windows does not implement POSIX signals: a graceful stop uses Node's
+ * default child termination, while a forced stop must include descendants.
+ */
+export function terminateProcess(
+  child: ChildProcess | undefined,
+  signal: ProcessTerminationSignal,
+  options: ProcessTerminationOptions = {},
+): Promise<boolean> {
+  if (!child || child.exitCode !== null || child.signalCode !== null) return Promise.resolve(false);
+
+  const platform = options.platform ?? process.platform;
+  if (platform === 'win32') {
+    if (signal !== 'SIGKILL') return killChild(child);

Review Comment:
   Fixed in `7b103e06b`: Windows now invokes `taskkill.exe /T /F` from the first termination stage, so `waitForTrial()` cannot return after killing only the supervisor. I added `process-termination.windows.test.ts`, which spawns a real supervisor and descendant on Windows and verifies that both exit after the first-stage `SIGTERM` request. Verified on Windows with Eval typecheck/build, repository lint/format, and the focused lifecycle suite (11 passed, 3 permission-related skips).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org