Hi Joerg,
Joerg Budischewski wrote:
Hi Kay,
hmm, your proposal looks more like a concept rather than an API proposal .
exactly! Everybody may implement it as appropriate, the point being that
all daemon threads eventually get joined, e.g when de-initializing a
shared library.
Will there be an API somewhere in sal for this ? If yes, I would rather
see the API docs before actually putting comments.
See above. I may make some helper functions available in SAL later on,
certainly along the lines of the example code.
Only critical point is the proper synchronization of the "activies" (AKA
non-daemon threads), as only the last one is allowed to call "exit".
I can't see how your concept should work work for daemon threads, when
shared libraries are dynamically loaded. From "man atexit"
--snip--
The atexit() function registers the given function to be called at
normal program termination, either via exit(3) or via return from the
program's main(). Functions so registered are called in the reverse
order of their registration; no arguments are passed.
--snap--
Dynamically using a shared library leads to registered atexit handlers
being called when "dlclose"ing.
See "man atexit":
Linux Notes
Since glibc 2.2.3, atexit() (and on_exit(3)) can be used within
a shared library to establish functions that are
called when the shared library is unloaded.
Though I don't know about other platforms. But "atexit" used by
dynamically opened libraries may be a problem anyway.
.. AFAIK, the static destructors of objects in shared libraries are
called by atexit functions, arent they ? So your daemon_join_ would be
called too late.
They are called at "atexit" time only in case of process termination,
otherwise they are called indirectly by "dlclose", so this is not a problem.
I'd rather prefer an explicit daemon_join in main() to avoid those kind
of problems ...
That would be wrong for daemons, as daemons are implementation details,
being implemented as needed.
Something similar is needed for activities (please see my example code),
to properly synchronize calling "exit".
Bye,
Joerg
Thanks for your help :-)
Kay
Kay Ramme - Sun Germany - Hamburg wrote:
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]