www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Simplifying process piping

reply Jesse Phillips <Jesse.K.Phillips+D gmail.com> writes:
As noted in this announcement, I started writing some basic 
tutorials for D.

https://forum.dlang.org/post/efpyegvrezybdrmugipd forum.dlang.org

At a post a week, I've got 10 weeks of backlog posts. One of 
these is a post on input output piping.

https://github.com/JesseKPhillips/std.process-example/

I'm wondering if there are any thoughts for simplification. I 
don't mean simplify to perform the same end result, but is the 
threading and data copies as simple as they could be? Did I 
misrepresent anything?
Sep 22 2019
parent Vladimir Panteleev <thecybershadow.lists gmail.com> writes:
On Sunday, 22 September 2019 at 16:06:04 UTC, Jesse Phillips 
wrote:
 https://github.com/JesseKPhillips/std.process-example/

 I'm wondering if there are any thoughts for simplification. I 
 don't mean simplify to perform the same end result, but is the 
 threading and data copies as simple as they could be? Did I 
 misrepresent anything?
Your approach is OK for more complicated cases. When you need to just pipe one process into another, create a `pipe`, pass the writeEnd to the first process's stderr, and the readEnd to the second process's stdin. To discard output, pass File("/dev/null", "w") to its stdout. There is a ticket somewhere in Bugzilla to add something like Python's Popen.communicate to pipe multiple things at once. it is not difficult, on Linux it is a select loop, doesn't even require threads. There was no consensus on what the interface should look like.
Sep 22 2019