Module: xenomai-3
Branch: wip/gpio
Commit: 83d7bfb0ee18db3709c709022039674307610965
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=83d7bfb0ee18db3709c709022039674307610965

Author: Philippe Gerum <r...@xenomai.org>
Date:   Mon Jun  6 20:34:10 2016 +0200

copperplate/heapobj-pshared: unlink main heap file on exit if no registry

sysregd removes the shared heap upon exit of the last process attached
to the session. When registry support is disabled, make sure the
backing file is unlinked upon exit of the main process.

---

 lib/copperplate/heapobj-pshared.c |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/lib/copperplate/heapobj-pshared.c 
b/lib/copperplate/heapobj-pshared.c
index bd9ea47..f4c6f37 100644
--- a/lib/copperplate/heapobj-pshared.c
+++ b/lib/copperplate/heapobj-pshared.c
@@ -29,6 +29,7 @@
 #include <errno.h>
 #include <stdio.h>
 #include <stdint.h>
+#include <stdlib.h>
 #include <string.h>
 #include <pthread.h>
 #include <unistd.h>
@@ -678,6 +679,19 @@ out:
        return ret;
 }
 
+#ifndef CONFIG_XENO_REGISTRY
+static void unlink_main_heap(void)
+{
+       /*
+        * Only the master process run this when there is no registry
+        * support (i.e. the one which has initialized the main shared
+        * heap for the session). When the registry is enabled,
+        * sysregd does the housekeeping.
+        */
+       shm_unlink(main_pool.fsname);
+}
+#endif
+
 static int create_main_heap(pid_t *cnode_r)
 {
        const char *session = __copperplate_setup_data.session_label;
@@ -770,6 +784,10 @@ reset:
        ret = fchown(fd, geteuid(), getegid());
        (void)ret;
 init:
+#ifndef CONFIG_XENO_REGISTRY
+       atexit(unlink_main_heap);
+#endif
+
        ret = ftruncate(fd, 0);  /* Clear all previous contents if any. */
        if (__bterrno(ret))
                goto unlink_fail;


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to