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.

        Long story short, if you fork(), you better exec(), and if you have
        nothing to exec(), exec() yourself (ie. recurse to run the same app
        after the fork with a special flag so that it doesn't recurse endlessly)

        All I can say is "read this":
        http://developer.apple.com/library/mac/#technotes/tn2083/_index.html

        ..and when you feel like your head will explode, have a cup of coffee
        and then read it again until it makes sense.

        In particular, take note:
        "Many Mac OS X frameworks do not work reliably if you call fork
         but do not call exec."

        This has something or other to do with how mach ports propagate from
        process to process, and without them, window manager stuff doesn't
        work properly. Expect to see weird error messages about CFMessagePort()
        and the like in consoles/kernel logs/stderr/etc.

        IMHO Apple has been taking shortcuts that break away from unix 
philosophy.
        I appreciate someone actually wrote this document describing the 
problem,
        but I hate that some OS designer allowed this to happen in the first 
place.
        It shouldn't have to be this way.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to