-
Han-Wen Nienhuys authored
Commit 1aa7b7b2 ("fs: document known deadlocks") describes a deadlock scenario where inheriting file descriptors triggers a spurious close during subprocess setup, leading to deadlock. This exact scenario actually happens when setting up the FUSE mount using fusermount: the fusermount process inherits one half of a socket pair, which is used to pass back the opened /dev/fuse file. After the mount is successful, we open a file in the FUSE mount for the poll hack. This means that in parallel scenarios, we may use fd 3 as the poll hack, while also calling fusermount with inherited file descriptors. Solve this by grabbing fd 3 during initialization. This is not completely foolproof, as FD 0, 1 and 2 could be closed (and then reused) after initialization finished, but this should be uncommon as 0, 1 and 2 are standard input/output/error. Doing it during the init phase means that we prevent deadlock for all users that inherit single file descriptors. Change-Id: If5ac7c941f0ee2e13ca657c31d056a676eed3fde
36b35911