On Fri, 10 Nov 2017 10:13:35 +0100 Anton Lindqvist <an...@openbsd.org> wrote:
> On Fri, Nov 10, 2017 at 09:36:25AM +0100, Martin Pieuchot wrote: > > On 09/11/17(Thu) 09:02, Helg Bredow wrote: > > > The current libfuse signal handling assumes that the file system will > > > always be unmounted by the child. One obvious case where this is not true > > > is if the file system is busy. To replicate: > > > > > > 1. mount a fuse file system > > > 2. cd anywhere on the file system > > > 3. pkill -INT <fuse exe> > > > > > > The result is a zombie child process and no more response to signals even > > > if the file system is no longer busy. > > > > > > This patch ensures that the child always exits and that an error is > > > printed to stdout if the file system cannot be unmounted. Tested with > > > fuse-exfat and ntfs_3g. Suggestions for improvement are welcome. > > > > Nice to see that you're fixing a bug. However I'd suggest you to go > > much further in your improvement. > > > > Signal handlers are hard and instead of doing work inside the signal > > handler you should toggle a global variable/flag and do this work > > inside the main loop (fuse_loop()?). > > > > For example your code below calls fprintf(3) in the signal handler. This > > is incorrect, this functions is not signal handler safe. What about > > fuse_unmount()? Are you sure it can be called from a signal handler? > > Some more info on making signal handlers asynchronous-safe: > > https://www.securecoding.cert.org/confluence/display/c/SIG30-C.+Call+only+asynchronous-safe+functions+within+signal+handlers Thanks for the feedback and info guys. I wasn't too confident with this patch and you've given me some good pointers to improve it. -- Helg <xx...@msn.com>