-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CommunicationHandle, an API for inter-process communication via Handles #308
Conversation
@Mistuke I have mostly taken the implementation from the following two modules in the GHC source code:
This PR is intended to replace all that code, providing an API for other consumers than just GHC. I have attempted to debug the two TODOs described in the OP with @bgamari. In particular, we hope you'd be able to comment about the WinIO-specific aspects; in particular, it seems that creating a pipe (using the |
c510bf7
to
c2933f8
Compare
I fixed the first bug, which is the same bug as GHC #24618 (as I got it from copying the code from The second bug is likely a bug in the compatibility |
@sheaf the Windows issues when using the old IO manager may indeed be attributable due to an infelicity in In my own local testing I have confirmed that |
ce35d1b
to
70df86e
Compare
@Mistuke Would it be possible for you to review the new |
70df86e
to
de7379d
Compare
So first thing to note, is that you cannot use async APIs (even in synchronous mode) with anonymous pipes. In general a consumer cannot assume anything about the handle it received. If the receiver wants to make it an async handle it has to do so. i.e. it has to call i.e.
But again, this does not work at all for anonymous pipes. This is why for WinIO process creates Named Pipes through note that WinIO can handle
It means your I/O throughput will drop but it should still work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks on the whole good to me, note that this never made it into the docs but explains some of the behavioral difference #235 (comment)
I do have one question, since you're making a new API, I wonder, should make the distinction between HANDLE and FDs? I think it would be better to only use HANDLE. i.e. only have usingPipes
. Named pipes should be readable through the same interfaces as anonymous ones. It's the inverse that's not true.
What I don't understand is that, with the first version of this PR, it worked fine for the parent to not use WinIO yet for the child to use WinIO. The parent will use
I have pushed a commit that uses only |
692df89
to
6a6970b
Compare
Using |
a98aecd
to
1c76258
Compare
efccb54
to
773934a
Compare
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
This commit modifies the SetupWrapper mechanism, adding a new way of building a package: directly calling Cabal library functions (e.g. 'build', 'configure' etc). This currently requires a bit of GADT trickery to accomodate the fact that configure returns a LocalBuildInfo which must then be passed to subsequent phases, while with the old Setup interface everything returns IO () and communication is done through the filesystem (the local build info file). To handle 'build-type: Hooks', this commit introduces the hooks-exe package, which contains: - the hooks-exe library, used to compile a set of SetupHooks into an external executable, - the hooks-cli library, which is used by cabal-install to communicate with an external hooks executable. This package depends on the new `CommunicationHandle` functionality from haskell/process#308.
NB This PR depends on #310. For review, please only look at the last commit (at the time of writing, this was a6af24e).
This PR adds the
System.Process.CommunicationHandle
module, which provides the cross-platformCommunicationHandle
abstraction which allowsHandle
s to be passed to child processes for inter-process communication.A high-level API is provided by the function
readCreateProcessWithExitCodeCommunicationHandle
, which can be consulted for further details about how the functionality is meant to be used.To test this functionality, I added the new
cli-child
executable component to the library. To work around Cabal bug #9854, it was necessary to change the build-type of the library toCustom
, in order to make thecli-child
executable visible when running the test-suite. The customSetup.hs
script contains more details about the problem.TODO:
associateHandleWithIOCP: invalid argument (The parameter is incorrect.)
. (To reproduce, runcabal run test -- +RTS -io-manager=native
; comment out all tests excepttestCommunicationHandle
intest/main.hs
for convenience.)let !output = force $ (reverse $ take 5 input) ++ "123"
tolet !output = force $ (reverse input) ++ "123"
, i.e. waiting for the end of the stream, then the test loops indefinitely.