Skip to content

Switch to new operation for obtaining file descriptors#20

Open
jeltsch wants to merge 1 commit into
biegunka:masterfrom
jeltsch:high-level-file-descriptor-acquisition
Open

Switch to new operation for obtaining file descriptors#20
jeltsch wants to merge 1 commit into
biegunka:masterfrom
jeltsch:high-level-file-descriptor-acquisition

Conversation

@jeltsch

@jeltsch jeltsch commented Sep 17, 2025

Copy link
Copy Markdown

There is an effort to move some GHC-specific modules out of base. Candidates for such moving are GHC.IO.Handle.Types and GHC.IO.Handle.Internals. These modules are often used for obtaining POSIX file descriptors from Haskell handles. Such a use is also present in the terminal-size package as part of the implementation of the hSize operation for POSIX.

There is a proposal to add dedicated operations for operating-system handle acquisition to base. A corresponding draft implementation can be found in GHC merge request !14732. The present pull request changes the implementation of hSize to use one of those new operations.

Note that this pull request slightly changes the behavior of the POSIX version of hSize, which previously returned Nothing when the given handle was not backed by a file descriptor but with the changes in this pull request throws an exception in such a situation. This actually makes the POSIX version of hSize behave analogous to the Windows version of hSize, which may be considered a good thing.

@Bodigrim

Bodigrim commented Jun 7, 2026

Copy link
Copy Markdown

@jeltsch presumably this needs some CPP to work with older GHCs?..
(Not a maintainer, just passing by)

@jeltsch

jeltsch commented Jun 7, 2026

Copy link
Copy Markdown
Author

Yes, this change just shows how to use the new operations. If compatibility with older GHC versions is wanted, then conditional compilation is needed.

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