<commit_before># Contained first is the system startup code.

# Re-setup all the stdio channels, to pull in new ivars

STDOUT.setup
STDIN.setup
STDERR.setup

begin
  Array.after_loaded
  Module.after_loaded

  Class.after_loaded
  Hash.after_loaded
  Kernel.after_loaded
  Math.after_loaded
  FileTest.after_loaded
  Thread.after_loaded
  Struct.after_loaded
  Signal.after_loaded
  ObjectSpace.after_loaded
  IO.after_loaded
  IO::BidirectionalPipe.after_loaded
  Object.after_loaded
  File.after_loaded
  String.after_loaded

  Ar.after_loaded

  ENV = EnvironmentVariables.new

  # define a global "start time" to use for process calculation
  $STARTUP_TIME = Time.now
rescue Object => e
  STDOUT << "Error detected running loader startup stage:\n"
  STDOUT << "  #{e.message} (#{e.class})\n"
  STDOUT << e.backtrace
  exit 2
end

# This is the end of the kernel and the beginning of specified
# code. We read out of ARGV to figure out what the user is
# trying to do.

Signal.action("INT") do |thr|
  # We can't raise on ourselves, we raise on main.
  if thr == Thread.current
    thr = Thread.main
  end

  # The current thread might be dead if all other live threads are
  # a sleep when the current one died.
  unless thr.alive?

    thr = Thread.main
    # If main is dead too. Wow. Ok.. well... tell the user.
    unless thr.alive?
      puts "Signal received, but the main thread is dead."
      puts "Unable to continue."
      exit! 1
    end
  end

  # Push the output down a little bit, makes things look more
  # obvious that the system was interrupted.
  puts
  thr.raise Interrupt, "Thread has been interrupted"
end

# Setup $LOAD_PATH.

additions = []

# The main stdlib location
additions << Rubinius::CODE_PATH

$LOAD_PATH.insert($LOAD_PATH.index('.'), *additions)

if ENV['RUBYLIB'] and not ENV['RUBYLIB'].empty? then
  $LOAD_PATH.unshift(*ENV['RUBYLIB'].split(':'))
end

# Pull it out now so that later unshifts don't obsure it.
main_lib = $LOAD_PATH.first

# Allow system wide code preloading
<commit_msg>Simplify and move SIGINT handler in kernel/loader.rb<commit_after># Contained first is the system startup code.

# Re-setup all the stdio channels, to pull in new ivars

STDOUT.setup
STDIN.setup
STDERR.setup

begin
  Array.after_loaded
  Module.after_loaded

  Class.after_loaded
  Hash.after_loaded
  Kernel.after_loaded
  Math.after_loaded
  FileTest.after_loaded
  Thread.after_loaded
  Struct.after_loaded
  Signal.after_loaded
  ObjectSpace.after_loaded
  IO.after_loaded
  IO::BidirectionalPipe.after_loaded
  Object.after_loaded
  File.after_loaded
  String.after_loaded

  Ar.after_loaded

  ENV = EnvironmentVariables.new

  # define a global "start time" to use for process calculation
  $STARTUP_TIME = Time.now
rescue Object => e
  STDOUT << "Error detected running loader startup stage:\n"
  STDOUT << "  #{e.message} (#{e.class})\n"
  STDOUT << e.backtrace
  exit 2
end

# Set up a handler for SIGINT that raises Interrupt on the main thread
Signal.action("INT") do |_|
  thread = Thread.main

  if thread.alive?
    thread.raise Interrupt, "Thread has been interrupted"
  else # somehow..?
    puts "Signal received, but the main thread is dead."
    puts "Unable to continue."
    exit! 1
  end
end

# This is the end of the kernel and the beginning of specified
# code. We read out of ARGV to figure out what the user is
# trying to do.

# Setup $LOAD_PATH.

additions = []

# The main stdlib location
additions << Rubinius::CODE_PATH

$LOAD_PATH.insert($LOAD_PATH.index('.'), *additions)

if ENV['RUBYLIB'] and not ENV['RUBYLIB'].empty? then
  $LOAD_PATH.unshift(*ENV['RUBYLIB'].split(':'))
end

# Pull it out now so that later unshifts don't obsure it.
main_lib = $LOAD_PATH.first

# Allow system wide code preloading

{'fraction_non_alphanumeric': 0.08764940239043825, 'fraction_numerical': 0.0010624169986719787, 'mean_word_length': 3.68407960199005, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 5, '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': '7082444', 'n_tokens_mistral': 1248, 'n_tokens_neox': 1202, 'n_words': 418}