[Qt-interest] return to command line but the GUI is still alive
Thiago Macieira
thiago at kde.org
Tue Jan 26 16:49:46 CET 2010
Em Terça-feira 26 Janeiro 2010, às 15:19:27, william.crocker at analog.com
escreveu:
> Thiago:
> > 2) if you used Qt code before the fork, then only one side of the fork
> > can use it afterwards. If you managed not to use in either side, then
> > it's ok to use it in both.
>
> I think this one deserves an explanation as well.
> (I know the reason because I got caught by it several years ago,
> but I'm sure other Qt users could benefit.)
>
> Better yet, give us a solution. My application requires
> a large quantity of code after the fork, and the inability
> to use Qt makes it very painful; I known all of those classes
> are there, but I can't use them.
The problem is the same as the other explanation: fork() marks all memory
pages as Copy-On-Write, but all other resources are shared.
What I said above counts as "official support". If you use Qt before the fork
and then in *both* sides after the fork, then you're out of support. It may or
may not work. It's entirely up to you to figure out what works and what
doesn't.
And then do the same again after the next release of Qt, because things
change.
This is not something that was decided. It's simply how things are when it
comes to fork().
Case in point: this will crash:
int main(int argc, char **argv)
{
QApplication app(argc, argv);
fork();
QPushButton btn;
btn.show();
app.exec();
}
And the explanation is what I said above. There's one resource that is shared
between parent and child processes that shouldn't be shared. (The X11 socket
connection)
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Senior Product Manager - Nokia, Qt Development Frameworks
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100126/6e47d533/attachment.bin
More information about the Qt-interest-old
mailing list