Skip to content

Instantly share code, notes, and snippets.

@benoittgt
Last active June 15, 2020 20:11
Show Gist options
  • Save benoittgt/434e39e631bea0c546691f9c91013e79 to your computer and use it in GitHub Desktop.
Save benoittgt/434e39e631bea0c546691f9c91013e79 to your computer and use it in GitHub Desktop.
Try to understand when things a done

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment