Sha256: 7b58b7dab9702f8a01f6ce82da082110779558babae350fa80474f499963906d

Contents?: true

Size: 1.89 KB

Versions: 24

Compression:

Stored size: 1.89 KB

Contents

childprocess
============

This gem aims at being a simple and reliable solution for controlling
external programs running in the background on any Ruby / OS combination.

The code originated in the selenium-webdriver gem, but should prove useful as
a standalone library.

[![Build Status](https://secure.travis-ci.org/jarib/childprocess.png)](http://travis-ci.org/jarib/childprocess)

Usage
-----
```ruby
process = ChildProcess.build("ruby", "-e", "sleep")

# inherit stdout/stderr from parent...
process.io.inherit!

# ...or pass an IO
process.io.stdout = Tempfile.new("child-output")

# modify the environment for the child
process.environment["a"] = "b"
process.environment["c"] = nil

# start the process
process.start

# check process status
process.alive?    #=> true
process.exited?   #=> false

# wait indefinitely for process to exit...
process.wait
process.exited?   #=> true

# ...or poll for exit + force quit
begin
  process.poll_for_exit(10)
rescue ChildProcess::TimeoutError
  process.stop # tries increasingly harsher methods to kill the process.
end
```

The object returned from ChildProcess.build will implement ChildProcess::AbstractProcess.

Implementation
--------------

How the process is launched and killed depends on the platform:

* Unix     : fork + exec (or posix_spawn if enabled)
* Windows  : CreateProcess and friends
* JRuby    : java.lang.{Process,ProcessBuilder}

Note on Patches/Pull Requests
-----------------------------

* Fork the project.
* Make your feature addition or bug fix.
* Add tests for it. This is important so I don't break it in a
  future version unintentionally.
* Commit, do not mess with rakefile, version, or history.
  (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
* Send me a pull request. Bonus points for topic branches.

Copyright
---------

Copyright (c) 2010-2012 Jari Bakken. See LICENSE for details.

Version data entries

24 entries across 24 versions & 7 rubygems

Version Path
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/childprocess-0.3.6/README.md
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/childprocess-0.3.6/README.md
childprocess-0.3.6 README.md
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/childprocess-0.3.5/README.md
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/childprocess-0.3.5/README.md
childprocess-0.3.5 README.md
childprocess-0.3.4 README.md
childprocess-0.3.3 README.md
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/childprocess-0.3.2/README.md
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/childprocess-0.3.2/README.md
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/childprocess-0.3.2/README.md
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/childprocess-0.3.2/README.md
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/childprocess-0.3.2/README.md
resque-pool-0.3.0 vendor/bundle/ruby/1.8/gems/childprocess-0.3.1/README.md
ftl-0.2.0 vendor/bundle/gems/childprocess-0.3.2/README.md
childprocess-0.3.2 README.md
frameworks-capybara-0.2.0.rc6 vendor/bundle/ruby/1.8/gems/childprocess-0.3.1/README.md
frameworks-capybara-0.2.0.rc5 vendor/bundle/ruby/1.8/gems/childprocess-0.3.1/README.md
frameworks-capybara-0.2.0.rc4 vendor/bundle/ruby/1.8/gems/childprocess-0.3.1/README.md
frameworks-capybara-0.2.0.rc3 vendor/bundle/ruby/1.8/gems/childprocess-0.3.1/README.md