[Bf-committers] Re: [Ghost-devel] Ghost and fork()
Vincent Caron
bf-committers@blender.org
Sun, 07 Sep 2003 22:36:56 +0200
Alexander Ewering wrote:
>
> I'm currently working on implementing a global multi-level UNDO
> feature (in addition to the already implemented editmode undo).
>
> For this, I'm following a suggestion from an ex-NaNer: For
> every operation that should be un-doable, just fork() and put
> the new child asleep (until it is awoken by a signal).
> When the user wants undo, the current process awakes the appropriate
> child (using a signal) and puts itself to sleep (using an endless
> loop in the style while (waiting) { PIL_sleep_ms(10); }, where
> "waiting" is set to 0 by a signal handler).
>
> This basically works fairly well, but there seem to be some
> OpenGL and X11-related problems.
I'm not sure about what you mean about 'global undo', but I believe it
can't work as is. fork() only replicate the process context, which in a
windowed environment is only the 'client' part of your program. The
allocated ressources on the serviced part of your application (graphical
window, pixmaps, widgets, etc) live a parallel life which is not
captured by your fork().
BTW, don't do polling and sleeps in processes, use a blocking call
(select(<empty fsset>, NULL) will do) which will simply exit when a
signal is received.
Hope it helps.