win: retain a shared console session - #22070
Open
radialmonster wants to merge 1 commit into
Open
Conversation
This was referenced Aug 29, 2026
radialmonster
marked this pull request as ready for review
August 30, 2026 00:05
Keep darktable attached to one console session so native system() and popen() children reuse it instead of allocating transient windows. When no console exists, dynamically request no-window allocation on Windows 11 24H2 and fall back to AllocConsole on older systems. Preserve caller-supplied standard handles and keep ordinary output in the existing log. Embed the console allocation policy while retaining the existing manifest settings. Related: darktable-org#17193
radialmonster
force-pushed
the
agent/windows-console-session-production
branch
from
August 30, 2026 00:40
50189c1 to
d18c086
Compare
lefth
approved these changes
Aug 30, 2026
lefth
left a comment
Contributor
There was a problem hiding this comment.
I'm not a heavy Lua user, but this seems to work well. There are no more console popups at startup or when I run a script like "show in file explorer". My Windows version is new enough that there is no extra terminal window present. My existing VBS launcher (which saves log output to a file) continues to work well.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This implements option 2 from
issue #17193, as
requested by @wpferguson: stop calling
FreeConsole()and retain one sharedconsole session for darktable's lifetime.
Keep darktable attached to one Windows console session so later
system()andpopen()children reuse it instead of allocating visible console windows.The patch extends the minimal
FreeConsole()removal for launch states wheredarktable starts without a console. In that case, it dynamically uses Windows
11 24H2's
AllocConsoleWithOptions()no-window mode. If that export isunavailable or the no-window allocation fails, it falls back to
AllocConsole(), which retains one visible console for the session.Caller-supplied disk and pipe standard handles are preserved; ordinary output
continues to use
Documents\Darktable\darktable-log.txt.The retained console is therefore normally blank: this patch does not expose
log messages there. Showing logs in the console would require a separate change
to darktable's existing Windows output-redirection policy.
The application remains a CUI executable. Its manifest preserves the existing
asInvokerand Windows compatibility declarations while adding the 24H2detached console-allocation policy. This suppresses the initial Explorer console
on supported systems without changing CMD or PowerShell wait behavior.
Related: #17193
Validation
BUILD_TESTING=ONbuild. After the final manifest-only formatting amend at
50189c133e, theaffected targets rebuilt and CTest passed 4/4.
windows and passed the full
dt.control.execute(),os.execute(), andio.popen()read/write/lines/status/close/GC contract.DETACHED_PROCESSlaunch also showed zeroconsole windows and passed the same contract.
--version,--help, and--gimp versionoutput and status wereunchanged, and a CMD probe waited for the CUI process to finish.
execution-level and supported-OS declarations plus the new allocation policy.
AllocConsoleWithOptions; runtime lookup keepsit loadable when that export is unavailable. A forced missing-export run used
the visible
AllocConsole()fallback, showed no child consoles, and passed thefull command contract.
Windows 10 22H2 Pro build 19045 and Windows 11 23H2 Pro build 22631. Both
systems lack the new export; both loaded the combined manifest, attached the
fallback console, shared it with a native child, and preserved redirected
stdin/stdout/stderr. This matrix used the exact packaged
50189c133ecandidate; each guest extracted the 1,026-byte final manifest and passed the
full command contract.
All runtime changes in
src/main.care inside its existing#ifdef _WIN32block. The manifest/resource wiring is inside CMake's existing
if(WIN32)block, and the resource file is Windows-only. Linux and macOS compile none of
the changed runtime or resource code.
Limitations
console for the darktable session. Closing that console or sending Ctrl+C
terminates darktable.
contracts were validated with the external investigation harnesses described
above.
AllocConsole()fail, later nativeshell children can allocate their own consoles.
CREATE_NEW_CONSOLEcan still create aseparate console window.
AI assistance
AI assisted with investigation, implementation, and validation.