QProcess 松散
我创建了两个程序 A 和 B。B 被设计为在 64 位 A 中启动的 32 位 QProcess。这些程序通过 stdin、stdout 和 QSharedMemory 进行良好的通信。
A:A() {
QProcess *p = new QProcess(this);
p->start("B.exe");
}
A:~A() {
p->deleteLater();
}
现在,如果 A 关闭,B 也将关闭。 但是,如果我在Windows任务管理器中结束进程A,B将继续逍遥法外,并且B的CPU使用率将飙升。为什么?
如果A立即被销毁,我如何关闭B?
I have created two programs A and B. B is designed to be as a 32-bits QProcess started within a 64-bits A. These programs communicate nicely via stdin, stdout and QSharedMemory.
A:A() {
QProcess *p = new QProcess(this);
p->start("B.exe");
}
A:~A() {
p->deleteLater();
}
Now, if A is closed B will also be shut down.
However, if I in Windows Task Manager ends the process A, B will keep living on the loose, and the cpu usage of B will be through the roof. Why?
How can I shut down B if A is immediately destroyed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试从 DTOR 中
close()
(或kill()
)其他进程,然后执行原始delete p
。我在使用 QextSerialPort 对象时遇到了类似的问题,当使用 deleteLater() 删除时,该对象也往往会像幽灵一样留下来,但在立即删除时会立即打包并离开。Try to
close()
(orkill()
) the other process from your DTOR and do a rawdelete p
afterwards. I had a similar issue when using a QextSerialPort object which, too, tended to stay around as a ghost when deleted with deleteLater(), however promptly packed up and left when immediately deleted.