Skip to content

Commit

Permalink
More places where we can not pass file descriptors.
Browse files Browse the repository at this point in the history
This is a follow up to 2615783. We can also use `:close_others`
in the reverse mounting case. Caught this because running the
test from test/misc/README.txt turned up a leaked process.
  • Loading branch information
dustymabe committed May 3, 2021
1 parent b5652a5 commit c50fb6e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/vagrant-sshfs/cap/guest/linux/sshfs_forward_mount.rb
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ def self.sshfs_slave_mount(machine, opts, hostpath, expanded_guest_path)
:thread_inherit => true,
:startup_info => {:stdin => w1, :stdout => r2, :stderr => f2})
else
p1 = spawn(sftp_server_cmd, :out => w2, :in => r1, :err => f1, :pgroup => true, :close_others=>true)
p2 = spawn(ssh_cmd, :out => w1, :in => r2, :err => f2, :pgroup => true, :close_others=>true)
p1 = spawn(sftp_server_cmd, :out => w2, :in => r1, :err => f1, :pgroup => true, :close_others => true)
p2 = spawn(ssh_cmd, :out => w1, :in => r2, :err => f2, :pgroup => true, :close_others => true)

# Detach from the processes so they will keep running
Process.detach(p1)
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-sshfs/cap/host/darwin/sshfs_reverse_mount.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def self.sshfs_mount(machine, opts)
:thread_inherit => true,
:startup_info => {:stdin => w2, :stdout => r1, :stderr => f1})
else
p1 = spawn(sshfs_cmd, :out => f1, :err => f1, :pgroup => true)
p1 = spawn(sshfs_cmd, :out => f1, :err => f1, :pgroup => true, :close_others => true)
Process.detach(p1) # Detach so process will keep running
end

Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-sshfs/cap/host/linux/sshfs_reverse_mount.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def self.sshfs_mount(machine, opts)
:thread_inherit => true,
:startup_info => {:stdin => w2, :stdout => r1, :stderr => f1})
else
p1 = spawn(sshfs_cmd, :out => f1, :err => f1, :pgroup => true)
p1 = spawn(sshfs_cmd, :out => f1, :err => f1, :pgroup => true, :close_others => true)
Process.detach(p1) # Detach so process will keep running
end

Expand Down
2 changes: 1 addition & 1 deletion test/misc/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ two should be different.

# Close our file descriptor. No other process should be using it
exec {extra_fd}>&-
if sudo lsof -wn -d $extra_fd | grep -q "$tmpfile"; then
if lsof -wn -d $extra_fd | grep "$tmpfile"; then
echo "Failure: there are processes running that hold an inherited file descriptor"
fi

0 comments on commit c50fb6e

Please sign in to comment.