#17916 closed defect (invalid)
VboxManage.exe spawns new window when exec run from docker-machine on windows 7
Reported by: | mrkbuttyhds | Owned by: | |
---|---|---|---|
Component: | other | Version: | VirtualBox 5.2.8 |
Keywords: | vboxmanage docker | Cc: | |
Guest type: | other | Host type: | Windows |
Description
When running docker-machine with vboxmanage version 5.2.8r121009 the pre-check always fails to detect the version or capture stdout because vboxmanage.exe spawns a new window.
I have recreated this with two scripts (golang and python) and when running the "vboxmanage --version" in the cmd cli it runs okay and output is in the same window but when execing the command from the scripts causes a new window to spawn so stdout cannot be captured.
Details here; https://stackoverflow.com/questions/51676072/vboxmange-command-spawns-new-window-tested-with-go-os-exec-run-why-how-do
Change History (9)
comment:1 by , 6 years ago
comment:2 by , 6 years ago
This sounds like a generic issue with Windows, so it's outside the scope of this tracker. Graphical apps (those which don't have a console window) and console apps (those which show their output in a cmd.exe or similar window) don't mix since only the latter have working stdin/out/err handling. Ask Microsoft for details.
comment:3 by , 6 years ago
Besides - especially from Python it'd be MUCH better if you'd directly use the VirtualBox API, and not rely on other code doing it for you. Error handling would be far superior.
comment:4 by , 6 years ago
The problem is this is how docker-machine runs the vboxmanage commands. So it fails and does not work! docker-machine is written in golang - in desperation to get this working I wrote the golang snippet to recreate how docker-machine calls the vboxmange.exe as per my posting above.
docker-machine source is available here; https://github.com/docker/machine
I will post a suggestion in a ticket open I have open with docker to use the api as an alternative.
comment:5 by , 6 years ago
Also I thought that vboxmanage.exe was using a console window? Is it launching as a GUI app rather than staying in the same cmd CLI?
If I run "vboxmanage --version > output.txt" it does not launch a new window!
comment:6 by , 6 years ago
vboxmanage is just a plain console app. Try using any other such app and you'll get the same result. E.g. running the script below with pythonw
:
import sys import subprocess sys.stdin = open("NUL", "r") sys.stdout = open("test.out", "w") sys.stderr = open("test.err", "w") print "hello" print subprocess.check_output(["C:\\Windows\\System32\\ARP.EXE", "-a"]) print "world"
will fail with
Traceback (most recent call last): File "test.py", line 12, in <module> print subprocess.check_output(["C:\\Windows\\System32\\ARP.EXE", "-a"] File "C:\Python27\lib\subprocess.py", line 567, in check_output process = Popen(stdout=PIPE, *popenargs, **kwargs) File "C:\Python27\lib\subprocess.py", line 703, in __init__ errread, errwrite), to_close = self._get_handles(stdin, stdout, stderr) File "C:\Python27\lib\subprocess.py", line 834, in _get_handles p2cread = self._make_inheritable(p2cread) File "C:\Python27\lib\subprocess.py", line 885, in _make_inheritable _subprocess.DUPLICATE_SAME_ACCESS) WindowsError: [Error 6] The handle is invalid
in test.err
comment:7 by , 6 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
VBoxManage
behaves just like any other Windows console program in the above test.
comment:8 by , 6 years ago
Looking closer, you seem to need ... , stdin = sys.stdin, stderr = sys.stderr)
on that
subprocess.check_output
call, then it works. No idea whatever that translates to in Go.
comment:9 by , 6 years ago
The problem appears to be environmental rather than the cause of docker, virtual box or windows. Please see thread; https://github.com/docker/machine/issues/4548
I found out it isn't Carbon Black causing the issue on my system!
The CB log files (confer.log) are very useful so I went looking through them. When launching vboxmanage I noticed that both docker-machine and my vboxtest.exe were being intercepted and vboxmanage was being run by windows\system32\pmlauncher.exe a google search indicated this was AVG but it isn't if you inspect the file it is described as "BeyondTrust PowerBroker for Windows Launcher".
There is a BeyondTrust PowerBroker service so I stopped this and then both the vboxtest.exe and the docker-machine commands work...
<stopped beyond trust> C:\temp>testvbox StdOut: "5.2.16r123759\r\n" <started beyond trust> C:\temp>testvbox StdOut: ""
I've also just tested with virtual-box 5.2.16 and vboxmanage 5.2.16r123759