On Wed, Aug 29, 2012 at 10:22 PM, Greg Ercolano <[email protected]> wrote:

> On 08/29/12 14:15, Greg Ercolano wrote:
> > On 08/29/12 06:01, Bogdan Popescu wrote:
> >> Hello everyone,
> >>
> >> I've recently migrated/rewrote our small communication application from
> >> Perl to C++ and used FLTK for the GUI part, the idea was to be able to
> >> start using it on Win/Mac rather than giving Linux boxes to users...
> >>
> >> As it's made of 2 pieces, the receiver (which is a daemon/service
> running
> >> under the user that is logged in) and the sender (a small app that
> search
> >> for and connect to the daemon/service running on the receiver's side), I
> >> needed the daemon to keep the FLTK code and make sure the window is
> >> displayed with the sender details... everything seems to work fine under
> >> Linux/X11, though on the Mac side the code compiles fine but some
> settings,
> >> mainly FL_Window::show(), fail under fork() and the child segfaults (and
> >> the window is not displayed), if I run the code without forking
> anything it
> >> seems to work fine... any idea how I could work around this problem or
> did
> >> I miss anything?
> >
> >       Oh man, don't get me started on Macs and its limitations with
> fork()
> >       and window manager stuff, esp. in the context of daemons.
> >  <mad rant>
>
>         BTW, sorry -- not ranting at you OP, I'm PO'ed at APPL's
>         OS designers.
>
>         The TN2083 thing is a giant PITA especially in the context of
>         distributed computing.
>
>         Perhaps doing one of their 'agent' approaches recommended in the
>         above tech note is best for your situation. Just be aware that this
>         means you can loose parent/child relationships, so you'll have to
> do
>         things like detect if one client/server have disappeared as part of
>         your protocol between them.
>
>         Or perhaps you can avoid this all with threads.
>

I'm not that good with threads... I gave it a go under Linux and it seems
to work fine for the first time it renders the window, after the second or
third try it might segfault (when calling Fl_Window::show() or Fl::run())
and you cannot close the window opened by FLTK, also the window is redrawn
when a new message is received instead of spawning a new one... I'm
thinking the way FLTK works with threads is different, right now I have all
my FLTK code under the last called function, do you think I need to/should
initialize fltk in main() and then spawn windows from the running threads?

Right now I replaced the fork calls with pthread (adding the
pthread_detach/join calls where needed), and stick Fl::lock/unlock in the
function that deals with FLTK...

I assume there must be a way of dealing with this without going for the
agent approach but thank you for your replies!


Regards,
Bogdan P.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to