Re: Using fork() in a GTK C/Vala application



On 15-09-01 07:27 AM, rastersoft wrote:
In fact, I'm already using pipes and more; I can just replace the Thread
call with a fork() and everything will work fine. The only idea I see I
can use is to physically separate both process in different binaries and
use named pipes...

On 01/09/15 16:05, Chris Vine wrote:
On Tue, 1 Sep 2015 15:33:19 +0200
rastersoft <raster rastersoft com> wrote:
Thanks for your answer. Unfortunately, I'm running out of options:
currently I'm using threads, but there is a nasty bug that makes my
program crash sometimes. It is very subtle, because it hapens usually
after being running for two-three days. It is a double free. I tried
with Valgrind, but when I use it, the error doesn't trigger, which
makes me suspect it is a race condition between both threads
(valgrind ensures that only one thread runs each time). I checked all
the code, and isolated everything as much as I could, and adding as
many locks as I could imagine, trying to remove that bug, but its
imposible, so I decided to separate the code in two independent
processes to be able to use valgrind and finally find what is
happening. But as you say, it seems I'll have to do something else...
Can you fork() before you launch any new threads or call any gio/gtk+
functions, and then perhaps communicate using pipes?  That should be
safe.

Chris
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

I have had similar problems and ended up using g_spawn_async_with_pipes() with a separate binary. This works well for me as I often need to launch several instances of this "thread".

jim...


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