Extending Ruby…quickly
Monday, September 25th, 2006I posted to the ruby-talk mailing list asking why the alarm() syscall isn’t available in Ruby. Logan Capaldo responded…by adding it.
% cat alarm.rb
require ‘dl/import’
module Alarm
extend DL::Importable
if RUBY_PLATFORM =~ /darwin/
so_ext = ‘dylib’
else
so_ext = ’so’
end
dlload “libc.#{so_ext}”
extern “unsigned [...]

