examples/passthrough_ll.c: Close root fd before application ends.
authorPrzemyslaw Pawelczyk <przemoc@gmail.com>
Mon, 28 Nov 2016 13:48:10 +0000 (14:48 +0100)
committerNikolaus Rath <Nikolaus@rath.org>
Tue, 29 Nov 2016 05:35:05 +0000 (21:35 -0800)
If we want to do, what system would do anyway upon program termination,
then let's try to be a bit more scrupulous.

example/passthrough_ll.c

index 9c6144a88c1165c492fa9a91dc165919d0402968..32e4ff6477e343c96777f1776c3053354b850cfa 100644 (file)
@@ -464,6 +464,7 @@ int main(int argc, char *argv[])
        int ret = -1;
 
        lo.root.next = lo.root.prev = &lo.root;
+       lo.root.fd = -1;
 
        if (fuse_parse_cmdline(&args, &opts) != 0)
                return 1;
@@ -515,6 +516,8 @@ err_out1:
 
        while (lo.root.next != &lo.root)
                lo_free(lo.root.next);
+       if (lo.root.fd >= 0)
+               close(lo.root.fd);
 
        return ret ? 1 : 0;
 }