Qt支持分支进程 [英] Does Qt support forked processes

查看:159
本文介绍了Qt支持分支进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当Qt应用程序中的 fork()时,Qt的哪些部分是正常的? Qt是否支持这个?

When I fork() in a Qt application, what parts of Qt behave sane? Does Qt support this?

很明显, MacOSX上的GUI不会工作,因为Cocoa本身不支持分支进程。

Obviously, e.g. the GUI on MacOSX will not work because Cocoa itself does not support forked processes.

但是还有很多其他部分,例如。线程列表等。

But there are many other parts, e.g. the list of threads, etc.

QCoreApplication :: applicationPid()似乎返回错误的值。 (根据此处。)

QCoreApplication::applicationPid() seems to return the wrong value. (According to here.)

或者让问题有点不同:我必须在我的应用程序中 fork(),并且某些部分可能访问Qt子进程。

Or to put the question a bit different: I must fork() in my app and there are certain parts which might access Qt in the child process. Where do I need to take extra care, despite all the Qt GUI stuff?

推荐答案

TL; DR 我需要特别小心, >我可以从Qt在叉子里使用什么? 任何东西,只要你通过代码审计证明自己没有与分支相关的错误。

TL;DR "What can I use from Qt in the fork?" "Anything, as long as you prove to yourself, via code audit, that there are no bugs there related to forking".

这些都没有被测试,所以没有人

None of this is tested for, so nobody knows if anything related to forking used to work, and got broken, and whether it still works.

Qt有一个持续的集成系统,它在多个平台上进行测试,作为一个工具,将更改转入未来版本的先决条件。这包括在关键领域测试性能回归。 IOW,它不是一个测试套件的笑话,它是真实的。在测试套件中没有解决分叉的事实应该是一个强有力的信号,表明你是自己在这里。

Qt has a continuous integration system and it is tested on multiple platforms as a prerequisite for staging the changes into a future release. This includes testing for performance regressions in the key areas. IOW, it's not a joke of a test suite, it's for real. The fact that forking is not addressed in the test suite should be a strong signal to you that you're on your own here.

因此,你需要在任何地方,并且您需要审计您调用的整个Qt代码。对不起,这是唯一合理的答案。

So, you need to take care everywhere, and you need to audit the entirety of Qt code that you call. Sorry, that's the only reasonable answer.

这篇关于Qt支持分支进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆