<commit_before>require File.expand_path('../../../spec_helper', __FILE__)

describe "Process.wait2" do
  before :all do
    # HACK: this kludge is temporarily necessary because some
    # misbehaving spec somewhere else does not clear processes
    begin
      leaked = Process.waitall
      puts "leaked before wait2 specs: #{leaked}" unless leaked.empty?
    rescue NotImplementedError
    end
  end

  platform_is_not :windows do
    it "returns the pid and status of child process" do
      pidf = Process.fork { Process.exit! 99 }
      results = Process.wait2
      results.size.should == 2
      pidw, status = results
      pidf.should == pidw
      status.exitstatus.should == 99
    end
  end
<commit_msg>Improve warnings when there are leaked process before the Process.wait2 specs<commit_after>require File.expand_path('../../../spec_helper', __FILE__)

describe "Process.wait2" do
  before :all do
    # HACK: this kludge is temporarily necessary because some
    # misbehaving spec somewhere else does not clear processes
    begin
      Process.wait(-1, Process::WNOHANG)
      $stderr.puts "Leaked process before wait2 specs! Waiting for it"
      leaked = Process.waitall
      $stderr.puts "leaked before wait2 specs: #{leaked}"
    rescue Errno::ECHILD # No child processes
    rescue NotImplementedError
    end
  end

  platform_is_not :windows do
    it "returns the pid and status of child process" do
      pidf = Process.fork { Process.exit! 99 }
      results = Process.wait2
      results.size.should == 2
      pidw, status = results
      pidf.should == pidw
      status.exitstatus.should == 99
    end
  end

{'fraction_non_alphanumeric': 0.08175716900549115, 'fraction_numerical': 0.011592434411226357, 'mean_word_length': 2.8862559241706163, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2613374', 'n_tokens_mistral': 492, 'n_tokens_neox': 470, 'n_words': 164}