Sha256: 2e4b3d2ff302451e86de185dac4bd46479fd4988b8230ef45baef84e22af0198

Contents?: true

Size: 1.24 KB

Versions: 78

Compression:

Stored size: 1.24 KB

Contents

module EventMachine

  # This is subclassed from EventMachine::Connection for use with the process monitoring API. Read the
  # documentation on the instance methods of this class, and for a full explanation see EventMachine.watch_process.
  class ProcessWatch < Connection
    # :stopdoc:
    Cfork = 'fork'.freeze
    Cexit = 'exit'.freeze
    # :startdoc:

    def receive_data(data) # :nodoc:
      case data
      when Cfork
        process_forked
      when Cexit
        process_exited
      end
    end

    # Returns the pid that EventMachine::watch_process was originally called with.
    def pid
      @pid
    end

    # Should be redefined with the user's custom callback that will be fired when the prcess is forked.
    #
    # There is currently not an easy way to get the pid of the forked child.
    def process_forked
    end

    # Should be redefined with the user's custom callback that will be fired when the process exits.
    #
    # stop_watching is called automatically after this callback
    def process_exited
    end

    # Discontinue monitoring of the process.
    # This will be called automatically when a process dies. User code may call it as well.
    def stop_watching
      EventMachine::unwatch_pid(@signature)
    end
  end

end

Version data entries

78 entries across 78 versions & 10 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/eventmachine-0.12.10/lib/em/process_watch.rb
classiccms-0.7.4 vendor/bundle/gems/eventmachine-0.12.10/lib/em/process_watch.rb
classiccms-0.7.3 vendor/bundle/gems/eventmachine-0.12.10/lib/em/process_watch.rb
MattHulse-eventmachine-0.0.1 lib/em/process_watch.rb
MattHulse-eventmachine-0.12.10 lib/em/process_watch.rb
eventmachine-eventmachine-0.12.8 lib/em/process_watch.rb
eventmachine-eventmachine-0.12.9 lib/em/process_watch.rb
classiccms-0.7.2 vendor/bundle/gems/eventmachine-0.12.10/lib/em/process_watch.rb
classiccms-0.7.1 vendor/bundle/gems/eventmachine-0.12.10/lib/em/process_watch.rb
classiccms-0.7.0 vendor/bundle/gems/eventmachine-0.12.10/lib/em/process_watch.rb
classiccms-0.6.9 vendor/bundle/gems/eventmachine-0.12.10/lib/em/process_watch.rb
classiccms-0.6.8 vendor/bundle/gems/eventmachine-0.12.10/lib/em/process_watch.rb
classiccms-0.6.7 vendor/bundle/gems/eventmachine-0.12.10/lib/em/process_watch.rb
classiccms-0.6.6 vendor/bundle/gems/eventmachine-0.12.10/lib/em/process_watch.rb
classiccms-0.6.5 vendor/bundle/gems/eventmachine-0.12.10/lib/em/process_watch.rb
classiccms-0.6.4 vendor/bundle/gems/eventmachine-0.12.10/lib/em/process_watch.rb
classiccms-0.6.3 vendor/bundle/gems/eventmachine-0.12.10/lib/em/process_watch.rb
classiccms-0.6.2 vendor/bundle/gems/eventmachine-0.12.10/lib/em/process_watch.rb
classiccms-0.6.1 vendor/bundle/gems/eventmachine-0.12.10/lib/em/process_watch.rb
classiccms-0.6.0 vendor/bundle/gems/eventmachine-0.12.10/lib/em/process_watch.rb