digitalmars.D - Write to stdin, read from stdout of a spawn command (a library)
- Victor Porton (7/7) Jan 23 2019 I want to write to stdin and read from stdout of an OS command I
- Victor Porton (9/16) Jan 23 2019 By the way, is it worth to rewrite this using fibers?
- Jon Degenhardt (6/26) Jan 23 2019 You've probably looked at std.process
- Kagamin (1/1) Jan 23 2019 See also http://libpipeline.nongnu.org/
I want to write to stdin and read from stdout of an OS command I spawn without deadlocks. (I have a string to write to stdin and want to read its stdout as a string.) Is there a ready D library for this? I wrote a C library for this and consider to port to D (either as bindings or as a rewrite): https://github.com/vporton/libcomcom
Jan 23 2019
On Wednesday, 23 January 2019 at 22:51:45 UTC, Victor Porton wrote:I want to write to stdin and read from stdout of an OS command I spawn without deadlocks. (I have a string to write to stdin and want to read its stdout as a string.) Is there a ready D library for this? I wrote a C library for this and consider to port to D (either as bindings or as a rewrite): https://github.com/vporton/libcomcomBy the way, is it worth to rewrite this using fibers? Fibers have the advantage that it becomes possible to run several spawn commands simultaneously. However, I suspect that usage of fibers may make the code even less efficient than the current approach which passes input and output as one string write/read operation, without any split of data into several I/O operations. What do you think?
Jan 23 2019
On Wednesday, 23 January 2019 at 23:23:47 UTC, Victor Porton wrote:On Wednesday, 23 January 2019 at 22:51:45 UTC, Victor Porton wrote:You've probably looked at std.process (https://dlang.org/phobos/std_process.html), but in case not, take a look, it may contain the building blocks you need. --JonI want to write to stdin and read from stdout of an OS command I spawn without deadlocks. (I have a string to write to stdin and want to read its stdout as a string.) Is there a ready D library for this? I wrote a C library for this and consider to port to D (either as bindings or as a rewrite): https://github.com/vporton/libcomcomBy the way, is it worth to rewrite this using fibers? Fibers have the advantage that it becomes possible to run several spawn commands simultaneously. However, I suspect that usage of fibers may make the code even less efficient than the current approach which passes input and output as one string write/read operation, without any split of data into several I/O operations. What do you think?
Jan 23 2019