--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 =3D~ /darwin/
> so_ext =3D 'dylib'
> else
> so_ext =3D 'so'
> end
> dlload "libc.#{so_ext}"
> extern "unsigned int alarm(unsigned int)"
> end
>=20
> trap("ALRM") do
> puts "Alarm!"
> exit
> end
>=20
> Alarm.alarm(3)
>=20
> loop {}
>=20
> % 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
--=20
Michael P. Soulier <>
"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)
iD8DBQFFF9rHKGqCc1vIvggRAmelAKCb25Wd9uLnMVswo3S0Ya QMWYqqRACgtm+f
tkjdudCs8/Xrv9fYOOvRrH0=
=7PNN
-----END PGP SIGNATURE-----
--SLauP2uySp+9cKYP--