Sha256: 154f34b4ecba8c06c23d2a752927c3fe33ca01fc2c353db4eee4074c2c7475df

Contents?: true

Size: 962 Bytes

Versions: 8

Compression:

Stored size: 962 Bytes

Contents

$:.unshift "../lib"
require 'eventmachine'
require 'test/unit'

if EM.kqueue?
  class TestProcessWatch < Test::Unit::TestCase
    module ParentProcessWatcher
      def process_forked
        $forked = true
      end
    end

    module ChildProcessWatcher
      def process_exited
        $exited = true
      end
      def unbind
        $unbind = true
        EM.stop
      end
    end

    def setup
      EM.kqueue = true
    end

    def teardown
      EM.kqueue = false
    end

    def test_events
      EM.run{
        # watch ourselves for a fork notification
        EM.watch_process(Process.pid, ParentProcessWatcher)
        $fork_pid = fork{ sleep }
        child = EM.watch_process($fork_pid, ChildProcessWatcher)
        $pid = child.pid

        EM.add_timer(0.2){
          Process.kill('TERM', $fork_pid)
        }
      }

      assert_equal($pid, $fork_pid)
      assert($forked)
      assert($exited)
      assert($unbind)
    end
  end
end

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
eventmachine-1.0.0.beta.2-x86-mswin32-60 tests/test_process_watch.rb
eventmachine-1.0.0.beta.2-x86-mingw32 tests/test_process_watch.rb
eventmachine-1.0.0.beta.2-java tests/test_process_watch.rb
eventmachine-1.0.0.beta.2 tests/test_process_watch.rb
eventmachine-1.0.0.beta.1-java tests/test_process_watch.rb
eventmachine-1.0.0.beta.1 tests/test_process_watch.rb
crusher-eventmachine-0.12.11 tests/test_process_watch.rb
jrmey-eventmachine-0.12.12 tests/test_process_watch.rb