Re: Gtkmm and fork()



So, Could you give me a  simple example showing how to use new thread and
fork()?


Chris Vine wrote:
> 
> On Fri, 9 Apr 2010 13:18:09 -0700 (PDT)
> "Adam Chyla [PL]" <adam chyla gmail com> wrote:
>> Hi. 
>> I have that code:
>> 
>> void MainWindow::on_ok_clicked()
>> {
>>    pid_t pid = fork(); // There is an error
>>    switch (pid)
>>    {
>> //...
>>    }
>> }
>> 
>> When I compiled program the gtkmm returns:
>> Mer: ../../src/xcb_io.c:249: process_responses: Assertion `(((long)
>> (dpy->last_request_read) - (long) (dpy->request)) <= 0)' failed.
>> Mer: ../../src/xcb_io.c:249: process_responses: Assertion `(((long)
>> (dpy->last_request_read) - (long) (dpy->request)) <= 0)' failed.
>> Aborted (core dumped)
> 
> This won't work.  X won't allow two processes to share the same
> resources.
> 
> If you are fork()ing to exec() another program, then you will need to
> start a new thread and fork() from that (the new process will only
> reproduce the thread of execution of the calling thread rather than
> the GUI thread, which is OK). However you can only call
> async-signal-safe functions between the fork() and the exec() in a
> multi-threaded process, so do any preparatory work before the fork().
> 
> If you are not fork()ing in order to exec() then you need either to do
> it all in threads or redesign your program.
> 
> Chris
> 
> 
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
> 
> 

-- 
View this message in context: http://old.nabble.com/Gtkmm-and-fork%28%29-tp28197014p28207756.html
Sent from the Gtkmm mailing list archive at Nabble.com.



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