From: <the...@gm...> - 2011-06-15 21:38:27
|
On Tue, Jun 14, 2011 at 2:06 AM, Hans Beckérus <han...@gm...> wrote: > On 2011-06-14 1:42, the...@gm... wrote: > 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. You do not need to use the fuse low level APIs to get to the struct fuse. You will not be able to use fuse_main() but you could use fuse_setup() or fuse_new(), which both return the struct fuse for the instance. You would then need to start the main loop. Before starting the main loop you could save the struct fuse in a static variable that your sighandler has access to. BTW fuse_new() will require you to do more setup which is handled by fuse_setup for you, but fuse_setup does call fuse_set_signal_handlers(). >>> 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. This is strange since the fuse signal handlers for the most part just call fuse_exit(). -nate |