--SLauP2uySp+9cKYP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On 25/09/06 Logan Capaldo said:

> Oops, sorry misunderstood the question. Is this better?
> % 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 int alarm(unsigned int)"
> end
> 
> trap("ALRM") do
>   puts "Alarm!"
>   exit
> end
> 
> Alarm.alarm(3)
> 
> loop {}
> 
> % ruby alarm.rb
> Alarm!

Impressive that you could write this so quickly. Still, shouldn't this be in
the standard library? I certainly don't want to do this with all of POSIX. :)

Thanks,
Mike
-- 
Michael P. Soulier <msoulier / digitaltorque.ca>
"Any intelligent fool can make things bigger and more complex... It
takes a touch of genius - and a lot of courage to move in the opposite
direction." --Albert Einstein

--SLauP2uySp+9cKYP
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFFF9rHKGqCc1vIvggRAmelAKCb25Wd9uLnMVswo3S0YaQMWYqqRACgtm+f
tkjdudCs8/Xrv9fYOOvRrH0pNN
-----END PGP SIGNATURE-----

--SLauP2uySp+9cKYP--