LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Can sub processing modify the parent's Gtk Widgets? (https://www.linuxquestions.org/questions/programming-9/can-sub-processing-modify-the-parents-gtk-widgets-395828/)

asnoka 12-22-2005 11:43 PM

Can sub processing modify the parent's Gtk Widgets?
 
Hi,everyone,I am new bie to Gtk programming,There is now a question puzzling me,I use fork syscall to create a sub process,and I want to modify the widgets in its father,for example,I want to modify the content of the label,However,when I coded it,I found perhaps In the sub process,I cannot modify the parent's widgets?

Is there some way to implement this?or it is definitely impossible to modify the parent's widgets in sub process.

I am a chineses boy,sorry for my poor english,thank you!

paulsm4 12-23-2005 11:22 PM

In general, file descriptors opened in one process are inherited by child processes ...
... but the MEMORY space in one process is separate and distinct from the memory space of any other process - even child processes.

So no, a GTK+ widget in a parent process cannot be directly manipulated by any of its children.

Two possible solutions:

1. Set up a communications channel between the parent and child.

The GTK+ "selections" mechanism might be a good way to do this:
http://developer.gnome.org/doc/API/g...elections.html

Alternatively, you could use any standard Unix IPC, from pipes through to message queues:

2. Use threads in a single process (instead of forking off child processes)

asnoka 12-24-2005 03:35 AM

thank you greatly,today i tried the signal and kill function,child processes send signal to the parent process,and the parent process modify the gtk widgets itself,it works.
I am not very familiar with IPC,but I have learned it before,I think its a good way to solve the question.
Thank you again!


All times are GMT -5. The time now is 01:03 AM.