Home > forkexec

forkexec

Forkexec is a project mainly written in Ruby, based on the MIT license.

Solution for Ruby timeout of external calls.

= forkexec

  • It's usefull for timeout actions running outside ruby eg. external system calls.
  • Executes given block in new forked process.
  • After timeout the forked process is killed and Timeout::Error is raised.
  • Return value of forked prcess is given through tmpfs in /dev/shm as serialized YAML object.
  • It's prototype = no tests, no doc, no warranty !

==example

require 'forkexec' => true

ForkExec.timeout(1){ exec "sleep 10"} Timeout::Error: PID 11185 timeouted from ./forkexec.rb:28:in `timeout' from (irb):2 from /usr/lib/ruby/1.8/x86_64-linux/rbconfig.rb:168

ForkExec.timeout(1){ "foo bar" if true} => "foo bar"

== Copyright

Copyright (c) 2010 Adam Kliment. See LICENSE for details.

Previous:olibs