在 QT 中重新附加到孤立进程
我们正在使用 Qt 准备一个应用程序,该应用程序有一个控制 GUI 的主进程,并生成执行实际数据处理的进程。使用 Qt 机制和 stdin/stdout 管道在主进程和数据处理进程之间交换消息。
现在,即使 GUI 崩溃,其他进程仍会继续运行。我们希望能够做的是,当新的 GUI 启动时,像以前一样重新连接到这些进程。有人知道这是否可能,如果可以,如何实现?
We're preparing an application using Qt that has a main process that controls the GUI and spawns processes that do the actual data processing. Messages are exchanged between the main process and the data-processing processes using the Qt mechanisms and the stdin/stdout pipes.
Now, in the event that the GUI crashes, the other processes keep running. What we'd like to be able to do is to, when a new GUI starts, reconnect to these processes as before. Anyone know if this is possible, and if so, how to achieve it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您使用命名管道与进程通信,这是可能的。如果 stdin/out 所属的进程终止,则 stdin/out 将关闭。
This is possible if you are using a named pipe for communicating with the process. stdin/out are closed if the process they belong to is terminated.
您可能想要研究进程之间通信的共享内存。我似乎记得在之前的工作中,它能够在非常相似的情况下恢复。
如果您的平台支持,另一种可能性是使用 dbus 进行进程之间的通信。如果是这种情况,则两个进程都不必在那里,但如果它正在运行,则会采取行动获取适当的消息。
You might want to investigate shared memory for the communication between processes. I seem to recall that it was able to recover in a very similar situation at a previous job.
Another possibility, if your platform supports it, is to use dbus for the communication between processes. If that is the case, neither process would have to be there, but will act get the appropriate messages if it is running.