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

# if run indirectly (eg via CI), kills the runner. TODO: needs guard
describe "Process.kill" do
  it "requires at least two arguments" do
    lambda { Process.kill }.should raise_error(ArgumentError)
    lambda { Process.kill(0) }.should raise_error(ArgumentError)
  end

  it "raises an ArgumentError for unknown signals" do
    lambda { Process.kill("FOO", 0) }.should raise_error(ArgumentError)
  end

  it "doesn't accept lowercase signal names" do
    lambda { Process.kill("hup", 0) }.should raise_error(ArgumentError)
  end

  it "doesn't tolerate leading or trailing spaces in signal names" do
    lambda { Process.kill(" HUP", 0) }.should raise_error(ArgumentError)
    lambda { Process.kill("HUP ", 0) }.should raise_error(ArgumentError)
  end

  it "accepts symbols as signal names" do
    Process.kill(:INFO, Process.pid).should == 1
  end

  platform_is_not :windows do
    it "tests for the existence of a process without sending a signal" do
      Process.kill(0, 0).should == 1
      pid = Process.fork {
        begin
          Signal.trap("HUP") { Process.exit! 99 }
          sleep(2) # only so that failures are cleaned up
        ensure
          Process.exit!
        end
      }

      # Give the child enough time to setup the HUP trap.
      sleep(0.5)

      Process.kill(0, pid).should == 1
      Process.kill(1, pid).should == 1
      Process.waitpid(pid)
      lambda { Process.kill(0, pid) }.should raise_error(Errno::ESRCH)
    end
  end

  if Process.uid != 0
    it "raises an EPERM if permission is denied" do
      lambda { Process.kill(1, 1) }.should raise_error(Errno::EPERM)
    end
  end
end
<commit_msg>Use SIGHUP instead of SIGINFO and trap the signal.<commit_after>require File.expand_path('../../../spec_helper', __FILE__)

# if run indirectly (eg via CI), kills the runner. TODO: needs guard
describe "Process.kill" do
  it "requires at least two arguments" do
    lambda { Process.kill }.should raise_error(ArgumentError)
    lambda { Process.kill(0) }.should raise_error(ArgumentError)
  end

  it "raises an ArgumentError for unknown signals" do
    lambda { Process.kill("FOO", 0) }.should raise_error(ArgumentError)
  end

  it "doesn't accept lowercase signal names" do
    lambda { Process.kill("hup", 0) }.should raise_error(ArgumentError)
  end

  it "doesn't tolerate leading or trailing spaces in signal names" do
    lambda { Process.kill(" HUP", 0) }.should raise_error(ArgumentError)
    lambda { Process.kill("HUP ", 0) }.should raise_error(ArgumentError)
  end

  platform_is_not :windows do
    it "accepts symbols as signal names" do
      begin
        flag = false
        @saved_trap = Signal.trap("HUP") { flag = true }
        Process.kill(:HUP, Process.pid).should == 1
        sleep 0.5
        flag.should == true
      ensure
        Signal.trap("HUP", @saved_trap)
      end
    end

    it "tests for the existence of a process without sending a signal" do
      Process.kill(0, 0).should == 1
      pid = Process.fork {
        begin
          Signal.trap("HUP") { Process.exit! 99 }
          sleep(2) # only so that failures are cleaned up
        ensure
          Process.exit!
        end
      }

      # Give the child enough time to setup the HUP trap.
      sleep(0.5)

      Process.kill(0, pid).should == 1
      Process.kill(1, pid).should == 1
      Process.waitpid(pid)
      lambda { Process.kill(0, pid) }.should raise_error(Errno::ESRCH)
    end
  end

  if Process.uid != 0
    it "raises an EPERM if permission is denied" do
      lambda { Process.kill(1, 1) }.should raise_error(Errno::EPERM)
    end
  end
end

{'fraction_non_alphanumeric': 0.10573525414514814, 'fraction_numerical': 0.012503397662408263, 'mean_word_length': 2.766632548618219, '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': '5292236', 'n_tokens_mistral': 1188, 'n_tokens_neox': 1116, 'n_words': 375}