diff options
author | Eric Wong <e@80x24.org> | 2018-07-01 01:54:15 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2018-07-02 01:24:15 +0000 |
commit | c0a29c0f7c829737782c18a0349b8655b3c0388d (patch) | |
tree | 2de91293179f6c48ce31dcd8514a2c2e4218ebd2 /bin/mwrap | |
download | mwrap-c0a29c0f7c829737782c18a0349b8655b3c0388d.tar.gz |
Diffstat (limited to 'bin/mwrap')
-rwxr-xr-x | bin/mwrap | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/bin/mwrap b/bin/mwrap new file mode 100755 index 0000000..17e3570 --- /dev/null +++ b/bin/mwrap @@ -0,0 +1,17 @@ +#!/usr/bin/ruby +# frozen_string_literal: true +require 'mwrap' +mwrap_so = $".grep(%r{/mwrap\.so\z})[0] or abort "mwrap.so not loaded" +cur = ENV['LD_PRELOAD'] +ENV['LD_PRELOAD'] = cur ? "#{mwrap_so}:#{cur}" : mwrap_so + +# work around close-on-exec by default behavior in Ruby: +opts = {} +if ENV['MWRAP'] =~ /dump_fd:(\d+)/ + dump_fd = $1.to_i + if dump_fd > 2 + dump_io = IO.new(dump_fd) + opts[dump_fd] = dump_io + end +end +exec *ARGV, opts |