Closed akshaykarle closed 9 years ago
Have u tried returning $?.
I use shellout or popen3 API calls for this. You can also use pipes to communicate , e.g. https://github.com/ranjib/lxc-extra/blob/master/lib/lxc/extra.rb On Aug 4, 2015 2:42 PM, "Akshay Karle" notifications@github.com wrote:
I've been trying to find ways to capture the exit status of the commands runs inside the container. I had a look at #attach and #run_command but couldn't find a way to capture the exit status. I naively tried somethings like:
container = LXC::Container.new('foo') container.start status = nil container.attach(wait: true) do status = system("false") p status #=> falseend p status #=> nil
Has anyone had this issue before? Any suggestions to get hold of the exit status?
— Reply to this email directly or view it on GitHub https://github.com/lxc/ruby-lxc/issues/32.
Thanks for the suggestion @ranjib. I tried to return $?
from the block passed to attach but it doesn't seem to return the same value as $?
. I've switched to using IO.pipe
to return the exit status as a workaround for now. I think we can close this issue, but would be a good if the gem supported something like this though.
I've been trying to find ways to capture the exit status of the commands runs inside the container. I had a look at #attach and #run_command but couldn't find a way to capture the exit status. I naively tried somethings like:
Has anyone had this issue before? Any suggestions to get hold of the exit status?