Monitor zombie process and insert result with a timestamp in a log file
while true; do ps axo pid=,stat= | awk '$2~/^Z/ { print }' | wc -l | ruby -pe 'print Time.now.strftime("[%T.%3N] ")' >> /tmp/ruby_bisect_zombie_process.log; sleep 0.1; done
Run the test with log inserted:
def function_logger(words)
open('/tmp/ruby_bisect_zombie_process.log', 'a') do |f|
f << "#{Time.now.strftime('[%T.%3N]')} #{words}\n"
end
end
it 'does not leave zombie processes', :unless => RSpec::Support::OS.windows? do
function_logger("before bisect")
bisect(%W[spec/rspec/core/resources/blocking_pipe_bisect_spec.rb_], 1)
function_logger("after bisect")
begin
expect(%x[ps -ho pid,state]).to_not include("Z")
ensure
function_logger("after ps")
end
Run the test with
bundle exec rspec spec/integration/bisect_spec.rb --format doc && echo "Done" | ruby -pe 'print Time.now.strftime("[%T.%3N] ")' >> /tmp/ruby_bisect_zombie_process.log