John, thanks for the explanation - makes sense.
the background of the question was: for the userland thread styles and minimal privileges for rtapi_app functionality, the 'forking helper program' is actually not helpful at all (it is needed and makes sense for kernel modules). Currently rtapi_app needs to run as root for io access and this isnt a great idea long run. This is why I consider replacing the rtapi_app helper by a vanilla rtapi demon program which will be started/stopped by the realtime script, and which is talked to through a Unix domain socket. I would drop the 'execute helper program' part in halcmd in that case. Since then no forking takes place the shm segment ownership issues shouldnt arise. - Michael Am 28.12.2012 um 15:13 schrieb John Kasunich: > > > On Thu, Dec 27, 2012, at 04:47 PM, Michael Haberler wrote: >> I'm trying to find a good reason for the following: >> >> - halcmd is also a HAL citizen with a temporary HAL module name (halcmdXXXX). >> - when halcmd loads a module by executing module_helper, it does the >> following: >> -- disconnect from hal, destroying its on hal module >> -- it runs module_helper >> -- after its completion, it re-creates its temporary hal module >> >> I fail to understand why - I would think it is good enough to release the >> lock on the hal data segment while module_helper is running. >> >> Any rationale for that? >> > > The short answer is probably "that was the easiest way to > make it work". I think there are problems with the shared > memory mapping if you try to have it active during a fork. > > I don't recall the details, but I think it was something like > the shared memory winds up belonging to the wrong > process. Or maybe it winds up belonging to both, but > of course the HAL housekeeping doesn't know that, and > when one of the processes ends, HAL closes the shared > memory, resulting in a segfault the next time the other > process tries to access it. > > Whatever the details, the simplest solution was to > disconnect from shared memory, do the fork, then > reconnect afterwards. > > Regards, > > John Kasunich > > ------------------------------------------------------------------------------ > Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and > much more. Get web development skills now with LearnDevNow - > 350+ hours of step-by-step video tutorials by Microsoft MVPs and experts. > SALE $99.99 this month only -- learn more at: > http://p.sf.net/sfu/learnmore_122812 > _______________________________________________ > Emc-developers mailing list > Emc-developers@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/emc-developers ------------------------------------------------------------------------------ Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and much more. Get web development skills now with LearnDevNow - 350+ hours of step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122812 _______________________________________________ Emc-developers mailing list Emc-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-developers