#!/usr/bin/ruby.ruby4.0 

fifo_dir  = 'tmp'
fifo_file = 'test_fifo'
fifo_path = ['.', fifo_dir, fifo_file].join('/')

trap 2 do
  File.delete(fifo_path)
  exit
end

Dir.mkdir(fifo_dir) unless Dir.exist?(fifo_dir)

`mkfifo #{fifo_path}` unless File.exist?(fifo_path)

input = open(fifo_path, 'r+')

loop do
  system input.gets
end
