Module: xenomai-3
Branch: master
Commit: 4364bdd358e893b1f4f7f644a35191b3fc7f4180
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4364bdd358e893b1f4f7f644a35191b3fc7f4180

Author: Philippe Gerum <r...@xenomai.org>
Date:   Tue Dec 27 09:45:35 2016 +0100

copperplate/regd: conform to libfuse assumption regarding SIGCHLD

When executing utility programs such as /bin/mount via a fork+exec
sequence, libfuse assumes that SIGCHLD won't be ignored by the forked
child, so that waitpid() may be safely used to wait for child
completion.

This means that SIGCHLD must not be ignored by the caller of
fuse_main() in the first place, since such signal disposition is
inherited.

It turned out that sysregd was actually ignoring SIGCHLD before
attempting to mount the system fs on behalf of fuse_main(), causing
libfuse's add_mount() to fail after ECHILD was received from
waitpid(), due to the following sequence of events:

registry_thread: fuse_main()
registry_thread:        add_mount()
registry_thread:                mount_pid = fork()
registry_thread:                execl("/bin/mount", ...)
/bin/mount:             ...
/bin/mount:             exit(0)
registry_thread:        waitpid(mount_pid, ...) => ECHILD

As a matter of fact, sysregd does not need any particular disposition
for SIGCHLD for carrying out its own duties, but has to start with
this signal set to SIG_IGN when spawned from copperplate (see
spawn_daemon()). The fix is to switch this signal disposition back to
SIG_DFL before the registry thread is started.

---

 lib/copperplate/regd/regd.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/copperplate/regd/regd.c b/lib/copperplate/regd/regd.c
index e0228fb..8752070 100644
--- a/lib/copperplate/regd/regd.c
+++ b/lib/copperplate/regd/regd.c
@@ -541,8 +541,9 @@ int main(int argc, char *const *argv)
 
        memset(&sa, 0, sizeof(sa));
        sa.sa_handler = SIG_IGN;
-       sigaction(SIGCHLD, &sa, NULL);
        sigaction(SIGPIPE, &sa, NULL);
+       sa.sa_handler = SIG_DFL;
+       sigaction(SIGCHLD, &sa, NULL);
 
        if (daemonize) {
                ret = daemon(1, 1);


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

Reply via email to