Module: xenomai-head Branch: master Commit: 9f706c9e3b0151330b6444b8a44c3b016c481fc8 URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=9f706c9e3b0151330b6444b8a44c3b016c481fc8
Author: Gilles Chanteperdrix <[email protected]> Date: Wed Aug 17 23:44:46 2011 +0200 native: allow applications to access native skin after fork --- src/skins/native/init.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/src/skins/native/init.c b/src/skins/native/init.c index 28385a6..2c36444 100644 --- a/src/skins/native/init.c +++ b/src/skins/native/init.c @@ -27,6 +27,7 @@ #include <asm/xenomai/bits/bind.h> int __native_muxid = -1; +static int fork_handler_registered; #ifndef HAVE___THREAD pthread_key_t __native_tskey; @@ -52,8 +53,21 @@ void __init_native_tskey(void) static __attribute__ ((constructor)) void __init_xeno_interface(void) { + int err; + __native_muxid = xeno_bind_skin(XENO_SKIN_MAGIC, "native", "xeno_native"); __native_muxid = __xn_mux_shifted_id(__native_muxid); + + if (fork_handler_registered) + return; + + err = pthread_atfork(NULL, NULL, &__init_xeno_interface); + if (err) { + fprintf(stderr, "Xenomai native skin init: " + "pthread_atfork: %s\n", strerror(err)); + exit(EXIT_FAILURE); + } + fork_handler_registered = 1; } _______________________________________________ Xenomai-git mailing list [email protected] https://mail.gna.org/listinfo/xenomai-git
