从 makefile 并行运行两个进程
我正在尝试运行服务器和客户端以从 makefile:
target:
./server&
./client
运行,问题是 server&即使我认为它应该在后台运行,也永远不会返回控制权。它不断监听从未被调用的客户端,因为 makefile 似乎没有从服务器拿回控制权。我该如何解决这个问题?无需编写任何额外的目标或脚本?
I am trying to run both a server and client to run from a makefile:
target:
./server&
./client
The problem is that server& never returns the control back even though I assume it should run in the background. It keeps listening for client which is never invoked as the makefile does not seem to get the control back from server. How can I solve this issue?. without writing any additional target or scripts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该能够通过将命令组合在一行上来完成此操作:
将命令行设置为 shell (
$(SHELL)
) 一次一行。或者,您可以定义两个独立的目标:
并使用
-j
选项运行 make 以使其并行化构建步骤:这似乎不是启动程序(例如用于测试)的最自然的解决方案,但可以使用当您有大量可以部分并行构建的构建规则时最好。 (有关
make
-s 目标并行化的更多控制,另请参阅You should be able to do this by combining the commands on a single line:
Make hands commandlines to the shell (
$(SHELL)
) one line at a time.Alternatively, you could define two independent targets:
and run make with the
-j
option to make it parallelize build steps:This would not appear the most natural solution for launching your program (e.g. for test) but works best when you have large numbers of build rules that can be partly built in parallel. (For a little more control on
make
-s parallellization of targets, see alsoserver
在后台运行。您可以使用命令fg
将其置于前台。然后用 Ctrl-C 杀死它或者用这个方法:
killall server
server
runs in background. You may put in foreground using commandfg
. And then kill it with Ctrl-COr maybe this method:
killall server