Summary
When I run a wasi binary with this library the stdout and stderr are directed towards the application's stdout and stderr. I would rather capture that information to present it in my own way. Is there an option for that which I am missing.
Additional details
Right now I'm working around this issue by futzing with the file descriptors for the program but this seems less than ideal.
def capturing_output
old_stdout = $stdout.dup
old_stderr = $stderr.dup
Tempfile.create '' do |stdout|
$stdout.reopen stdout.path, 'w+'
Tempfile.create '' do |stderr|
$stderr.reopen stderr.path, 'w+'
yield
stdout.read
rescue RuntimeError
raise ScriptError.new stdout.read, stderr.read, $!.message
end
ensure
$stdout.reopen old_stdout
$stderr.reopen old_stderr
end
end
capturing_output do
Wasmer::Instance.new(module_, import).exports._start.()
end
It's both overly complicated and requires the use of files which is IO I would prefer to avoid. I expect my output to be very small so it would be ideal if I could provide a StringIO object to avoid that disk access.
Summary
When I run a wasi binary with this library the stdout and stderr are directed towards the application's stdout and stderr. I would rather capture that information to present it in my own way. Is there an option for that which I am missing.
Additional details
Right now I'm working around this issue by futzing with the file descriptors for the program but this seems less than ideal.
It's both overly complicated and requires the use of files which is IO I would prefer to avoid. I expect my output to be very small so it would be ideal if I could provide a StringIO object to avoid that disk access.