You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should expose our withHandleFd function somewhere because when you want to do something like fchmod() (which needs an Fd) on the Handle, the most luring solution is System.Posix.IO's handleToFd, which is brutally wrong because
This function has the side effect of closing the Handle
If you use handleToFd (which I just did on my server, oops), it will just mark the Handle as closed (but keep the underlying Fd open), so then the hClose that unliftio does will be silently ignored, and the Fd will be leaked until the server crashes (and so did mine).
So I think we should make our better withHandleFd publicly available, and write somewhere in the module that this is what should be used if you need low-level FD access from withBinaryFile*.
@nh2 I remember when you where reviewing my PR about this functionality you wanted to make it more general. I do like that idea, but I do not agree that such API should provided by unliftio. The purpose of this package is to provide OS agnostic UX, which means exporting functions that operate on unix Fds will be sending the wrong message the user. What I would recommend is that someone extracts the posix file operations provided in this package and re-designs them to be generic enough to be reusable in other areas and situations, withHandleFd is a great example of such function. Once such package is available then unliftio can use it instead of defining specialized functions for handling atomic file operations the way it does now.
We should expose our
withHandleFd
function somewhere because when you want to do something likefchmod()
(which needs anFd
) on theHandle
, the most luring solution isSystem.Posix.IO
'shandleToFd
, which is brutally wrong becauseIf you use
handleToFd
(which I just did on my server, oops), it will just mark theHandle
as closed (but keep the underlying Fd open), so then thehClose
that unliftio does will be silently ignored, and the Fd will be leaked until the server crashes (and so did mine).So I think we should make our better
withHandleFd
publicly available, and write somewhere in the module that this is what should be used if you need low-level FD access fromwithBinaryFile*
.cc @lehins
The text was updated successfully, but these errors were encountered: