Sha256: aa357375c95a7ce14f7868a10500214ce4904dbd0e97852dbbb3abaebabcb5b5

Contents?: true

Size: 1.31 KB

Versions: 9

Compression:

Stored size: 1.31 KB

Contents

# Subexec
by Peter Kieltyka
http://github/nulayer/subexec

## Description

Subexec is a simple library that spawns an external command with
an optional timeout parameter. It relies on Ruby 1.9's Process.spawn
method. Also, it works with synchronous and asynchronous code.

Useful for libraries that are Ruby wrappers for CLI's. For example,
resizing images with ImageMagick's mogrify command sometimes stalls
and never returns control back to the original process. Enter Subexec.

Tested with MRI 1.9.3, 1.9.2, 1.8.7

Note: Process.spawn seems to be broken with JRuby 1.7.0.dev (as of
April 20th, 2012), and so it uses Process.exec instead.

## Usage

```ruby
sub = Subexec.run "echo 'hello' && sleep 3", :timeout => 5
puts sub.output     # returns: hello
puts sub.exitstatus # returns: 0

sub = Subexec.run "echo 'hello' && sleep 3", :timeout => 1
puts sub.output     # returns: 
puts sub.exitstatus # returns:`
```

## Limitations

Only Ruby 1.9 can spawn non-blocking subprocesses, via Process.spawn.
So Ruby 1.8 support is sheerly for backwards compatibility. 

## Windows Support

Limited Windows support is available. We are more than happy to accept patches.
However, our tests are run on Unix-like operating systems. Primarily, the intended
effect should be that Subexec *works* on Windows, though it may not give
many advantages.

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
subexec-0.2.3 README.md
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/subexec-0.2.2/README.md
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/subexec-0.2.2/README.md
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/subexec-0.2.2/README.md
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/subexec-0.2.2/README.md
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/subexec-0.2.2/README.md
rails-uploader-0.0.4 vendor/bundle/ruby/1.9.1/gems/subexec-0.2.2/README.md
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/subexec-0.2.2/README.md
subexec-0.2.2 README.md