|
From: Hans B. <han...@gm...> - 2011-06-14 06:06:37
|
On 2011-06-14 1:42, the...@gm... wrote: > On Mon, Jun 13, 2011 at 6:05 PM, Hans Beckérus<han...@gm...> wrote: >> I stumbled into a design issue that forces me to leave the basic >> fuse_main() approach and instead take the long turn using fuse_new() etc. >> The problem I then got into is that eg. SIGTERM does not automatically >> unmount my fs and I can not figure out how to register a exit handler. >> To be able to umount the fs both mount point and channel is needed. How >> can I easily register a exit handler that can pick up the data needed >> for me to call fuse_unmount() and fuse_exit() ? Also, is it enough to >> call fuse_unmount() and fuse_destroy() or should I use fuse_teardown() >> instead? > If you want your filesystem to call fuse_exit it will have to be done > from either a separate thread or as part of signal handler. Once the > main loop exits you can then call the unmount and destroy. When the > umount goes through the kernel fuse_session_exit is called > automatically by the channel receiver. > Thanks for the input. Actually I already knew that fuse_exit() needs to be called from another thread or signal handler. I do have unmount and clean-up code after my event loops stops. But the problem is not when the event loop is stopped in a controlled fashion. I need to call fuse_exit() also for eg. SIGINT (CTRL-C). Registering my own signal handler for SIGINT could solve that, but then I do not know how to easily propagate the struct fuse* to be able to call fuse_exit() for the correct instance. That is why I want to register a exit handler instead on session level using the fuse_session_ops::exit. But I can not find a suitable API function that can do that? And I do not want to go through fuse_create_session() which means I need to start using the fuse_lowlevel API. > fuse_teardown() calls fuse_unmount_common() and fuse_destroy() for > you. It will also call fuse_remove_signal_handlers() which resets HUP, > INT, TERM and PIPE to their default values. The only warning I would > give for usingfuse_teardown() is that it also tries to free > mountpoint. If you don't want mountpoint to be freed then you are > better off calling fuse_unmount() and fuse_destroy() separately. > Great. I will remember that. >> I tried to use fuse_set_signal_handlers() but that just made things >> worse :( Then I could not even break out of the foreground process using >> CTRL-C. >> Hmm, actually this was not working as expected. Using a *very* dirty trick I managed to register my own exit handler in fuse_session_ops (that is why I need some help doing it the proper way). Then if I also call fuse_set_signal_handlers() and just leave the exit handler empty, fuse_exit() is called automatically at SIGINT and my event loop terminates nicely. But, If I do not register a exit handler and only call fuse_set_signal_handlers() SIGINT does not work, eg. fuse_exit() is never called and clean-up is not possible! This I can not explain. > -nate |