Created: 2012-03-22 05:03
Updated: 2014-01-02 02:29
License: mit



This module provides an interface to POSIX::Spawn for EventMachine. In particular, it contains an EventMachine equivalent to POSIX::Spawn::Child. This class encapsulates writing to the child process its stdin and reading from both its stdout and stderr. Only when the process has exited, it triggers a callback to notify others of its completion. Just as POSIX::Spawn::Child, this module allows the caller to include limits for execution time and number of bytes read from stdout and stderr.


Please refer to the documentation of POSIX::Spawn::Child for the complete set of options that can be passed when creating Child.

require "em/posix/spawn"

EM.run {
  p = EM::POSIX::Spawn::Child.new("echo something")

  p.callback {
    puts "Child process echo'd: #{p.out.inspect}"

  p.errback { |err|
    puts "Error running child process: #{err.inspect}"


The implementation for EM::POSIX::Spawn::Child and its tests are based on the implementation and tests for POSIX::Spawn::Child, which is Copyright (c) 2011 by Ryan Tomayko r@tomayko.com and Aman Gupta aman@tmm1.net.

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more