|
From: Hans B. <han...@gm...> - 2011-06-16 09:23:40
|
The problem was never to get hold of the fuse object handle. The problem was how to modify the exit callback in struct fuse_session_ops without having to use the fuse_lowlevel API. The fuse_session_ops structure is "hidden" and its definition only available through fuse_i.h, which is not part of the API itself. But knowing how the struct was declared I could hack around it. But in the end I actually did not have to ;) Using the provided API to register signal handlers was enough. For some reason it did not work when I tried the first time, but after some more testing (and also checking the implementation which is very straight forward) I came to the conclusion that my non-interruptable process was caused by something else. And it was, I still do not know why, but it works fine now. Thanks. Hans 2011/6/15 <the...@gm...>: > 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 > |