vagrant-landrush / landrush

A Vagrant plugin that provides a simple DNS server for Vagrant guests
MIT License
666 stars 78 forks source link

ISSUE #249 Fixing inherited file handles #250

Closed bexelbie closed 8 years ago

bexelbie commented 8 years ago

On Mac and Linux the DNS server spawn code automatically inherited filehandles for STDIN, STDOUT, and STDERR. This fix closes those filehandles and sets all other filehandles to not explicitly redirected to uninherited.

This is already the default for Windows.

This fix is thanks to @dustymabe and his research on a similiar issue for vagrant-sshfs https://github.com/dustymabe/vagrant-sshfs/issues/41

bexelbie commented 8 years ago

This also fixes https://github.com/projectatomic/adb-atomic-developer-bundle/issues/513

coolbrg commented 8 years ago

Verified the patch by running the VagrantLauncher.java program as

$ java VagrantLauncher <which vagrant> <Dir path of Vagrantfile> <user name> <password>

Found that the stdout and stderr stream thread are closed

ERROR>
ERROR>DEBUG ssh: stdout: Successfully started and provisioned VM with 2 cores and 3072 MB of memory.
.............
OUTPUT>==> default: You can now access the OpenShift console on: https://openshift.cdk:8443/console
ERROR>DEBUG ssh: stdout: 
ERROR>
ERROR>DEBUG ssh: stdout: To use OpenShift CLI, run:
ERROR>
ERROR> INFO interface: info: To use OpenShift CLI, run:
ERROR> INFO interface: info: ==> default: To use OpenShift CLI, run:
OUTPUT>==> default: To use OpenShift CLI, run:
ERROR>DEBUG ssh: stdout: $ vagrant ssh
ERROR>$ oc login
ERROR>
ERROR> INFO interface: info: $ vagrant ssh
ERROR>$ oc login
ERROR> INFO interface: info: ==> default: $ vagrant ssh
ERROR>==> default: $ oc login
OUTPUT>==> default: $ vagrant ssh
OUTPUT>==> default: $ oc login
.............
ERROR>DEBUG ssh: stdout: If you have the oc client library on your host, you can also login from your host.
ERROR>
ERROR> INFO interface: info: If you have the oc client library on your host, you can also login from your host.
ERROR> INFO interface: info: ==> default: If you have the oc client library on your host, you can also login from your host.
OUTPUT>==> default: If you have the oc client library on your host, you can also login from your host.
ERROR>DEBUG ssh: stdout: 
ERROR>
ERROR>DEBUG ssh: Exit status: 0
ERROR> INFO warden: Calling OUT action: #<Proc:0x00000001e53d18@/opt/vagrant/embedded/gems/gems/vagrant-1.8.4/lib/vagrant/action/warden.rb:94 (lambda)>
....................
ERROR> INFO warden: Calling OUT action: #<Vagrant::Action::Builtin::Call:0x00000003894e70>
ERROR> INFO warden: Calling OUT action: #<VagrantPlugins::ProviderVirtualBox::Action::CheckVirtualbox:0x00000003894e98>
ERROR> INFO interface: Machine: action ["up", "end", {:target=>:default}]
ERROR> INFO environment: Released process lock: machine-action-23094bb78005cd19e7080392623f720c
ERROR>DEBUG environment: Attempting to acquire process-lock: dotlock
ERROR> INFO environment: Acquired process lock: dotlock
ERROR> INFO environment: Released process lock: dotlock
ERROR> INFO environment: Running hook: environment_unload
ERROR> INFO runner: Preparing hooks for middleware sequence...
ERROR> INFO runner: 2 hooks defined.
ERROR> INFO runner: Running action: environment_unload #<Vagrant::Action::Builder:0x00000003a06010>
waitFor returned:0
output thread died
error thread died

LGTM :+1:

dustymabe commented 8 years ago

LGTM - but note I did not test this myself, so it's worth $.02

bexelbie commented 8 years ago

merged.