0.7.2 --- a channel's ends reach only the program they are placed in - #21
Merged
Conversation
A start with inheritance enabled gives the program every inheritable handle of the process. kal_process_channel created the far end inheritable, so it reached every program started while it existed: a child whose input was a channel held the writing end of its own input and never saw the end of it, and a program started meanwhile kept another program's pipe open. Both ends are now created non-inheritable, as the descriptor implementations create both close-on-exec, and kal_process_spawn marks the handles it places only for the length of the start, restoring each and holding a lock across it.
This was referenced Sep 13, 2026
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.
A child whose standard input was a channel never saw the end of its input on Windows, and a program started while a channel existed kept that channel open.
CreateProcessWwith inheritance enabled gives the started program every inheritable handle of the process, not only the three in its start-up record.kal_process_channelcreated the far end inheritable from the moment it existed, so it reached:The two descriptor implementations create both ends close-on-exec for this reason and let the spawn place the far one deliberately. This makes Windows do the same:
kal_process_channel: both ends are created non-inheritable.kal_process_spawn: the handles it places are marked inheritable for the length ofCreateProcessWonly, each is restored to its previous state afterwards (a borrowed standard stream is the caller's), and an SRW lock serializes that window so a start on another context cannot receive them.src/win32.h,port/kernel32.def:GetHandleInformation,AcquireSRWLockExclusive,ReleaseSRWLockExclusive.Measured locally, with lsp-mcpp built for
x86_64-windows-gnuover openkal-llvm-runtime → openkal-musl → this tree, under Wine:The objects still reference no C runtime symbol in the dev and release profiles, and every declared name is exported by a
.def.