Re: XServer connection?



>   Some days ago I wrote an e-mail talking about how can a GTK application 
>forked can get a XServer connection. 
>   Some answers told me to look in old e-mais of GTK-list, but I am writing 

no, not old emails. the FAQ. but anyway, on closer inspection, thats
not the issue you have.

>again because I didnīt found what I would like to know. 
>   I have a GTK application that has a button. When it button is clicked its 
>callback function calls fork(). Then the child application re-build all the 
>graphical interface, calling gtk_init() too. 

from this description, i don't believe this will work. the child
inherits the parent's connection to the X server. you would need to
completely shut it down before proceeding. what is happening is that
both the parent and child are effectively sharing the same link to the
X server, and this cannot work for all the same reasons that
multithreaded programs have specific design issues. gtk_init() is
idempotent() - calling it once or 100 times makes no difference.

you need to rethink your design. generally the only reason to fork in
situations like this is to then call exec(2). calling fork and then
continuing to run a GTK interface in the child is not "normal".

--p



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]