Skip to content

MSW: make interrupting Maxima more robust (#2289) - #2402

Merged
gunterkoenigsmann merged 3 commits into
mainfrom
claude/fix-msw-interrupt
Sep 29, 2026
Merged

gunterkoenigsmann merged 3 commits into
mainfrom
claude/fix-msw-interrupt

Conversation

@gunterkoenigsmann

@gunterkoenigsmann gunterkoenigsmann commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Requested by Gunter · project thread

Before: On some Windows systems Ctrl+G only showed "Could not send an interrupt signal to maxima.", and the user had to restart Maxima and lost the session (#2289). The message never said why.

After: wxMaxima now finds the Lisp's shared-memory segment even when Maxima didn't report its pid. When interrupting fails, the log says which segments were tried and what Windows reported. The console Ctrl+C fallback is gone, because it never worked.

How:

  • Finding the segment. The interrupt sets a bit in the shared-memory segment gcl-<pid> or maxima-<pid>, named after the Lisp's pid. We only know that pid if Maxima's first prompt reported it; otherwise the name was built from maxima.bat's pid and never matched. Now every process below the one we started is tried as well. The process-tree walk is a pure, portable function, DescendantPids() in src/ProcessTree.{h,cpp}, with a unit test that covers reused pids and cycles.
  • Dropping the fallback. It sent a Ctrl+C to wxMaxima's own console. wxmaxima.exe is a GUI-subsystem program without one, and Maxima leads a new process group, which ignores Ctrl+C.
  • Error text. FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER …) was passed the buffer pointer instead of its address, so Windows' error text was always lost. It is now passed correctly.

The real fix for threaded Lisps, a channel of wxMaxima's own, is #2405, which is stacked on this PR.

Testing: the Linux build is clean and all unit tests pass, including the new ProcessTree test. The Windows-only code compiles with MinGW-w64 against stubbed wx types; the minGW CI job does the real build. Not tested on real Windows.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BUfW6XqBP4WxRKwDCu4dBS

The interrupt sets a bit in a shared-memory segment named after the Lisp's
pid. That pid is only known if Maxima's first prompt reported it; otherwise
the name was built from the pid of maxima.bat and the segment wasn't found.
Now every process below the one wxMaxima started is tried as well
(DescendantPids(), a pure function with a unit test).

The fallback sent a Ctrl+C to wxMaxima's own console, which wxmaxima.exe,
a GUI-subsystem program, does not have. It now attaches to Maxima's hidden
console for that.

FormatMessage() was handed the buffer pointer instead of its address, so
the reason Windows gave for a failure was always lost; it is reported now,
together with the segment names that were tried.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BUfW6XqBP4WxRKwDCu4dBS
It never worked: wxmaxima.exe has no console to send a Ctrl+C from, and
Maxima leads a new process group, which ignores Ctrl+C. A failed interrupt
now says so instead of trying it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BUfW6XqBP4WxRKwDCu4dBS
@gunterkoenigsmann
gunterkoenigsmann marked this pull request as ready for review September 29, 2026 17:01
@gunterkoenigsmann
gunterkoenigsmann merged commit 7d4c958 into main Sep 29, 2026
18 of 20 checks passed
@gunterkoenigsmann
gunterkoenigsmann deleted the claude/fix-msw-interrupt branch September 29, 2026 17:01
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