64 Commits

Author SHA1 Message Date
hashicorp-copywrite[bot]
36a312ee26
add missing license headers and update copyright file headers to BUS-1.1 2023-08-10 21:53:25 +01:00
Chris Roberts
914530d26a
Use trace log level for noisy log messages 2022-04-25 12:26:19 -05:00
sophia
ee90e11832 Test detach option 2020-06-30 17:24:25 -05:00
sophia
384e327b9e Add detach option to Util::Subprocess 2020-06-30 15:59:39 -05:00
Chris Roberts
a4eb002750 Use ld path of system libs with appimage libs suffixed 2019-02-04 12:52:55 -08:00
Chris Roberts
6009492e73 Detect AppImage and update executable environment if required
If starting a process while running from within AppImage adjust
the LD_LIBRARY_PATH of the subprocess when the executable exists
outside of the AppImage. This prevents issues of invalid dynamic
library lookups when the AppImage contains common named libraries.
2018-07-31 10:39:26 -07:00
Chris Roberts
c555e4b72f Remove subprocess command string re-encoding to default external 2017-03-23 09:16:27 -07:00
Chris Roberts
903428e569 Add Util::Subprocess#stop and Util::Subprocess#running? 2017-02-08 14:15:47 -08:00
Chris Roberts
1f5dd35d16 Remove bundler where no longer required 2016-11-07 20:00:38 -08:00
Jake Teton-Landis
ceb69e6266 Allow closing a Vagrant::Util::Subprocess's STDIN
Previously, there was no way to close the STDIN stream of a subprocess,
so commands that read from stdin in a subprocess would hang forever,
such as `/bin/sh -s`. If one tried to close the stdin, the
IO.select() call in Subprocess#execute would raise an error for calling
select() on a closed IO.

Here's a concrete example of a command that needs to close STDIN to work
properly:

```ruby
script = SOME_VERY_LONG_STRING
command = %w(ssh foo.example.com /bin/sh -s foo bar)
result = ::Vagrant::Util::Subprocess.execute(*command) do |type, data_or_io|
  if type == :stdin
    data_or_io.write(script)
    data_or_io.write("\n")
    data_or_io.close
    next
  end

  puts "Remote: #{data_or_io}"
end
```
2016-09-04 16:45:38 -07:00
Mitchell Hashimoto
dec5f70a1e core: fix jailbreaking of plugins
/cc @sethvargo
2015-07-10 15:34:59 -06:00
Seth Vargo
fafa3fa437 Add another log statement 2015-07-09 16:06:03 -06:00
Seth Vargo
68ef9676c7 Jailbreak out of the subprocess and restore original environment 2015-07-09 16:06:03 -06:00
Seth Vargo
50a64ea30b Add a log statement 2015-07-09 16:06:02 -06:00
Seth Vargo
0a5d37fc8b Reset the original environment if we are running something outside of the installer 2015-07-09 16:06:02 -06:00
Seth Vargo
3ba10b43ab Restore the original environment from Bundler and the installer if given 2015-07-09 13:14:34 -06:00
Mitchell Hashimoto
bb25bb3be9 core: actually get the proper encoded subprocess command [GH-5128] 2015-07-06 14:39:50 -06:00
Mitchell Hashimoto
2385305f6f core: Don't encode! since string might be frozen 2014-12-10 09:27:00 -08:00
Mitchell Hashimoto
370ca050db Merge pull request #3707 from takekazuomi/fix/master/encodeissue
fix subprocess external encode issue.
2014-10-23 23:18:19 -07:00
Fabian Ruff
c72c8dce40 Selecting for duration of timeout can cause hang
When specifying a timeout, the subprocess used to select for timeout seconds on the stdout, stderr pipes.

This creates a race condition and can cause the `Subprocess#execute` to hang for the full timeout interval if the process has already exited and no more output is send to the pipes.

This race is happening with a higher probability if the subprocess is generating a lot of output.
2014-08-12 21:00:02 +02:00
Fabian Ruff
47de3225dd Subprocess: respect listeners on final yield 2014-07-31 11:32:25 +02:00
Kalman Hazins
bb052366f7 Change symbols inside hashes to 1.9 JSON-like syntax 2014-05-22 12:35:12 -04:00
Takekazu Omi
7da9648089 fix subprocess external encode issue. https://github.com/mitchellh/vagrant/issues/3706
in io.rb
 subprocess resuts convert external encoding to utf-8

in subprocess.rb
 command line argument convert utf-8 to  external encoding
2014-05-08 17:59:45 +09:00
Mitchell Hashimoto
ec35190cfc core: use process.alive? to avoid exceptions 2014-04-13 14:24:25 -07:00
Mitchell Hashimoto
8bfb4bda2b core: make sure any Subprocess exits no matter what 2014-02-12 21:35:54 -08:00
Mitchell Hashimoto
a6be44125d core: Seperate out IO util helper 2014-01-16 22:46:25 -08:00
Mitchell Hashimoto
138024d74c core: Unset DYLD_LIBRARY_PATH if setuid/setgid [GH-2243] 2013-09-20 17:43:11 -07:00
Mitchell Hashimoto
47120a86a2 core: modify DYLD_LIBRARY_PATH only if executing in installer [GH-2231] 2013-09-20 17:38:49 -07:00
Mitchell Hashimoto
5b2a28cd4c core: set the DYLD_LIBRARY_PATH before other env vars 2013-09-18 09:42:18 -07:00
Mitchell Hashimoto
7c3b342add core: restore the old DYLD_LIBRARY_PATH specifically 2013-09-18 09:41:57 -07:00
Mitchell Hashimoto
06bf3c6fdc core: Remove DYLD_LIBRARY_PATH if command not in installer [GH-2219] 2013-09-17 18:53:35 -07:00
Mitchell Hashimoto
7adffcb880 CHANGELOG 2013-07-16 16:34:53 -07:00
korya
a0774b5b5f Vagrant reports properly error for not found command 2013-07-15 08:52:53 +03:00
Mitchell Hashimoto
5f5203559f style nitpick 2013-07-12 16:05:56 +09:00
Mitchell Hashimoto
6c99f3dfa7 tweaks for style 2013-06-09 13:51:19 -07:00
Gabor Nagy
a4979c4824 [GH-654] Missing condition and translations 2013-06-03 00:04:25 +02:00
Gabor Nagy
4c00abe69e Modifies to use util/which [GH-654] 2013-06-02 03:48:47 +02:00
Gabor Nagy
0936267314 Fixes [GH-654] on Windows 8x64 and Ruby 1.9.3p374
Replaces the command with absolute path version if it exists.
2013-06-01 14:29:45 +02:00
Mitchell Hashimoto
d1eccbf98f SafeChdir all the things for thread safety 2013-04-03 08:31:43 -07:00
Mitchell Hashimoto
bd60d6b283 Lock around chdir in Subprocess for thread safety 2013-04-03 08:31:43 -07:00
Fabio Rehm
cc20d2f91e raise ChildProcess::LaunchError with the original message to ease debugging when running subprocesses 2013-03-09 15:31:28 -03:00
Mitchell Hashimoto
165dd63f78 New HandleBoxUrl built-in middleware to handlet the "box_url" config 2013-02-01 11:31:08 -08:00
Mitchell Hashimoto
4e6496bed7 Improve subprocess logging 2013-01-31 19:47:54 -08:00
Mitchell Hashimoto
c75ec09014 Lower IO.select timeouts to improve subprocess speeds
We were getting bit if the process exited while we were doing an
IO.select because it would then wait the full timeout.
2013-01-30 21:29:04 -08:00
Mitchell Hashimoto
5bc0fa1dff Default the IO.select result to empty array to avoid nil errors 2012-06-28 08:22:06 -07:00
Mitchell Hashimoto
0b9173efd9 Handle case that writers is nil on IO.select in subprocess
This can happen when IO.select timeout is reached when we're listening
for writers.
2012-06-27 13:54:05 -07:00
Mitchell Hashimoto
b393de052f Subprocess now only yields stdout/stderr if you're listening 2012-06-01 23:17:48 +02:00
Mitchell Hashimoto
1a6ae81aa9 Require what to be notified for with block and Subprocess.execute
There was an issue before where the stdin buffer would always have space
so it would always yield that block and Ruby would spin at 100%. Now we
require all callers to say what they want to listen for. This drops
CPU down to almost nothing.

See GH-832
2012-06-01 17:02:12 +02:00
Mitchell Hashimoto
a90f33dcf2 Avoid deadlock behavior on Windows subprocess IO [GH-765] 2012-02-28 09:44:28 -08:00
Mitchell Hashimoto
0ba3824106 Windows subprocess IO works again. [GH-721] 2012-02-10 00:53:22 -08:00