Proposal: add createPipe to base

I've written a cross-platform* implementation of the pipe() syscall, currently for use within Cabal: createPipe :: IO (Handle, Handle) https://github.com/haskell/cabal/blob/master/Cabal/tests/Distribution/Compat... It's a bit of a shame to leave it in Cabal as it's generally useful. I propose we add it to System.IO. Note that we'd have to copy the 5 lines in System.Posix.IO.createPipe into base as the above implementation would otherwise depend on the unix package. Discussion period: 3 weeks. * Only tested on OS X, Windows, and Linux.

On Mon, Mar 10, 2014 at 2:30 PM, Johan Tibell
I've written a cross-platform* implementation of the pipe() syscall, currently for use within Cabal:
createPipe :: IO (Handle, Handle)
https://github.com/haskell/cabal/blob/master/Cabal/tests/Distribution/Compat...
It's a bit of a shame to leave it in Cabal as it's generally useful.
I propose we add it to System.IO. Note that we'd have to copy the 5 lines in System.Posix.IO.createPipe into base as the above implementation would otherwise depend on the unix package.
Discussion period: 3 weeks.
* Only tested on OS X, Windows, and Linux.
+1. I've needed this in the past when working with process, and ended up writing POSIX-only code as a result.

On Mon, Mar 10, 2014 at 02:32:06PM +0200, Michael Snoyman wrote:
On Mon, Mar 10, 2014 at 2:30 PM, Johan Tibell
wrote: I propose we add it to System.IO. Note that we'd have to copy the 5 lines in System.Posix.IO.createPipe into base as the above implementation would otherwise depend on the unix package.
+1. I've needed this in the past when working with process, and ended up writing POSIX-only code as a result.
Would it make more sense to put it in process, and thus avoid needing to copy/move code into base? Thanks Ian

On Mon, Mar 10, 2014 at 1:47 PM, Ian Lynagh
On Mon, Mar 10, 2014 at 2:30 PM, Johan Tibell
I propose we add it to System.IO. Note that we'd have to copy the 5
On Mon, Mar 10, 2014 at 02:32:06PM +0200, Michael Snoyman wrote: lines
in System.Posix.IO.createPipe into base as the above implementation would otherwise depend on the unix package.
+1. I've needed this in the past when working with process, and ended up writing POSIX-only code as a result.
Would it make more sense to put it in process, and thus avoid needing to copy/move code into base?
I'm certainly open to that idea. If the only uses of pipes are for processes, I think that makes sense. Are there any typical non-process uses of pipes? I can't think of any right now. -- Johan

On Mon, Mar 10, 2014 at 8:54 AM, Johan Tibell
On Mon, Mar 10, 2014 at 1:47 PM, Ian Lynagh
wrote: On Mon, Mar 10, 2014 at 2:30 PM, Johan Tibell
I propose we add it to System.IO. Note that we'd have to copy the 5
On Mon, Mar 10, 2014 at 02:32:06PM +0200, Michael Snoyman wrote: lines
in System.Posix.IO.createPipe into base as the above implementation would otherwise depend on the unix package.
+1. I've needed this in the past when working with process, and ended up writing POSIX-only code as a result.
Would it make more sense to put it in process, and thus avoid needing to copy/move code into base?
I'm certainly open to that idea. If the only uses of pipes are for processes, I think that makes sense. Are there any typical non-process uses of pipes? I can't think of any right now.
I know of one in C, and it seems potentially applicable to Haskell as well, but it's mostly(?) a Unix-ism: you allocate a pipe, write to it in a signal handler, and monitor the read end in an event loop (in Haskell, a thread) in order to change an asynchronous signal that may have happened when it's unsafe to e.g. allocate memory into a synchronous event that can be handled safely. Note that you must use an unbuffered write from System.Posix.IO to write from the signal handler safely, so this introduces a hard dependency on the `unix` package; although there may be a win32 equivalent. -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

On Mar 10, 2014 1:54 PM, "Johan Tibell"
On Mon, Mar 10, 2014 at 1:47 PM, Ian Lynagh
wrote: On Mon, Mar 10, 2014 at 02:32:06PM +0200, Michael Snoyman wrote:
On Mon, Mar 10, 2014 at 2:30 PM, Johan Tibell
wrote:
I propose we add it to System.IO. Note that we'd have to copy the 5
in System.Posix.IO.createPipe into base as the above implementation would otherwise depend on the unix package.
+1. I've needed this in the past when working with process, and ended up writing POSIX-only code as a result.
Would it make more sense to put it in process, and thus avoid needing to copy/move code into base?
I'm certainly open to that idea. If the only uses of pipes are for
lines processes, I think that makes sense. Are there any typical non-process uses of pipes? I can't think of any right now. Yes: transferring data from one socket to another in a zero-copy fashion using the 'splice' syscall in Linux requires passing stuff through a pipe (used as a buffer). I for one wouldn't consider a dependency on 'process' to write such code (if I ever would in Haskell...) to be a problem though. Nicolas

On Mon, Mar 10, 2014 at 2:47 PM, Ian Lynagh
On Mon, Mar 10, 2014 at 2:30 PM, Johan Tibell
I propose we add it to System.IO. Note that we'd have to copy the 5
On Mon, Mar 10, 2014 at 02:32:06PM +0200, Michael Snoyman wrote: lines
in System.Posix.IO.createPipe into base as the above implementation would otherwise depend on the unix package.
+1. I've needed this in the past when working with process, and ended up writing POSIX-only code as a result.
Would it make more sense to put it in process, and thus avoid needing to copy/move code into base?
I have no opinion on where it should go, process would be fine with me. Michael

I propose we add it to System.IO. Note that we'd have to copy the 5 lines in System.Posix.IO.createPipe into base as the above implementation would otherwise depend on the unix package.
+1. I've needed this in the past when working with process, and ended up writing POSIX-only code as a result.
+1 one from me, with a preference for process over base. Cheers, Stefan

Since everyone is in favor, I will add createPipe to the process package,
as most people seemed to prefer that to base.
On Tue, Mar 11, 2014 at 6:08 AM, Stefan Holdermans wrote: I propose we add it to System.IO. Note that we'd have to copy the 5
lines
in System.Posix.IO.createPipe into base as the above implementation
would
otherwise depend on the unix package. +1. I've needed this in the past when working with process, and ended up
writing POSIX-only code as a result. +1 one from me, with a preference for process over base. Cheers, Stefan

+1 for me.
I have a slight preference for putting it in process over base given that
we're considering a mass exodus of material from base in a couple of years
and it'd be one more thing to move, but it is a very slight preference.
-Edward
On Mon, Mar 10, 2014 at 8:30 AM, Johan Tibell
I've written a cross-platform* implementation of the pipe() syscall, currently for use within Cabal:
createPipe :: IO (Handle, Handle)
https://github.com/haskell/cabal/blob/master/Cabal/tests/Distribution/Compat...
It's a bit of a shame to leave it in Cabal as it's generally useful.
I propose we add it to System.IO. Note that we'd have to copy the 5 lines in System.Posix.IO.createPipe into base as the above implementation would otherwise depend on the unix package.
Discussion period: 3 weeks.
* Only tested on OS X, Windows, and Linux.
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

On 2014-03-10 at 13:30:05 +0100, Johan Tibell wrote:
I've written a cross-platform* implementation of the pipe() syscall, currently for use within Cabal:
createPipe :: IO (Handle, Handle) https://github.com/haskell/cabal/blob/master/Cabal/tests/Distribution/Compat...
It's a bit of a shame to leave it in Cabal as it's generally useful.
I propose we add it to System.IO. Note that we'd have to copy the 5 lines in System.Posix.IO.createPipe into base as the above implementation would otherwise depend on the unix package.
+1 from me (with a preference to put it in 'process' if that's still on the table)

The link below is 404'd, but... I seem to remember that on Windows there are subtleties to do with whether the pipe ends are inheritable by subprocesses or not. See mkAnonPipe() in the process package for how we deal with this already in process. +1 for having it in process. Cheers, Simon On 10/03/2014 12:30, Johan Tibell wrote:
I've written a cross-platform* implementation of the pipe() syscall, currently for use within Cabal:
createPipe :: IO (Handle, Handle) https://github.com/haskell/cabal/blob/master/Cabal/tests/Distribution/Compat...
It's a bit of a shame to leave it in Cabal as it's generally useful.
I propose we add it to System.IO. Note that we'd have to copy the 5 lines in System.Posix.IO.createPipe into base as the above implementation would otherwise depend on the unix package.
Discussion period: 3 weeks.
* Only tested on OS X, Windows, and Linux.
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries
participants (9)
-
Brandon Allbery
-
Edward Kmett
-
Herbert Valerio Riedel
-
Ian Lynagh
-
Johan Tibell
-
Michael Snoyman
-
Nicolas Trangez
-
Simon Marlow
-
Stefan Holdermans