FIFO /Named Pipes in D?

ⅰ亾dé卋堺 提交于 2019-12-23 16:26:50

问题


I am trying to do the following :

A central application, let us call it alpha, accepts user inputs in command lines, and based on those inputs, spawns other processes, call them bravo, charlie, etc. I want the parent and child to communicate both way. That is, alpha can read from and write to bravo (resp. charlie) and vice-versa

In C++, i can use fork() then exec(), and use FIFO-s - some excellent tutorials, are here : Pipe, Fork, and Exec - Two Way Communication Between Parent and Child Process and http://pronix.linuxdelta.de/C/Linuxprogrammierung/Linuxsystemprogrammieren_C_Kurs_Kapitel5b.shtml

But, I am wondering if the same, is also possible in D? I dont find much from web searching.


回答1:


As it happens, I remember your previous post here and drew a conclusion two questions are related. For what you asked in the previous question (Switch cas Alternative in D) you really do not need some complex interprocess communication - you basically need to call std.process.execute() and get the output. Think of it as a function similar to popen().

Check that thread, and see how I implemented a very basic "fact" command using execute()... You should be able to build a much more robust solution on top of that code if you implement all necessary checks.




回答2:


It looks like D's standard library supports creating pipes and child processes.

http://dlang.org/phobos/std_process.html



来源:https://stackoverflow.com/questions/19845837/fifo-named-pipes-in-d

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!