Class: EventMachine::ProcessWatch
- Inherits:
-
Connection
- Object
- Connection
- EventMachine::ProcessWatch
- Defined in:
- lib/em/process_watch.rb
Overview
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.
Constant Summary collapse
- Cfork =
:stopdoc:
'fork'.freeze
- Cexit =
'exit'.freeze
Instance Attribute Summary
Attributes inherited from Connection
Instance Method Summary collapse
-
#pid ⇒ Object
Returns the pid that EventMachine::watch_process was originally called with.
-
#process_exited ⇒ Object
Should be redefined with the user’s custom callback that will be fired when the process exits.
-
#process_forked ⇒ Object
Should be redefined with the user’s custom callback that will be fired when the prcess is forked.
-
#receive_data(data) ⇒ Object
:startdoc:.
-
#stop_watching ⇒ Object
Discontinue monitoring of the process.
Methods inherited from Connection
#associate_callback_target, #close_connection, #close_connection_after_writing, #comm_inactivity_timeout, #comm_inactivity_timeout=, #connection_completed, #detach, #error?, #get_outbound_data_size, #get_peer_cert, #get_peername, #get_pid, #get_sock_opt, #get_sockname, #get_status, #initialize, new, #notify_readable=, #notify_readable?, #notify_writable=, #notify_writable?, #pause, #paused?, #pending_connect_timeout, #pending_connect_timeout=, #post_init, #proxy_incoming_to, #proxy_target_unbound, #reconnect, #resume, #send_data, #send_datagram, #send_file_data, #set_comm_inactivity_timeout, #set_pending_connect_timeout, #ssl_handshake_completed, #ssl_verify_peer, #start_tls, #stop_proxying, #stream_file_data, #unbind
Constructor Details
This class inherits a constructor from EventMachine::Connection
Instance Method Details
#pid ⇒ Object
Returns the pid that EventMachine::watch_process was originally called with.
21 22 23 |
# File 'lib/em/process_watch.rb', line 21 def pid @pid end |
#process_exited ⇒ Object
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
34 35 |
# File 'lib/em/process_watch.rb', line 34 def process_exited end |
#process_forked ⇒ Object
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.
28 29 |
# File 'lib/em/process_watch.rb', line 28 def process_forked end |
#receive_data(data) ⇒ Object
:startdoc:
11 12 13 14 15 16 17 18 |
# File 'lib/em/process_watch.rb', line 11 def receive_data(data) # :nodoc: case data when Cfork process_forked when Cexit process_exited end end |
#stop_watching ⇒ Object
Discontinue monitoring of the process. This will be called automatically when a process dies. User code may call it as well.
39 40 41 |
# File 'lib/em/process_watch.rb', line 39 def stop_watching EventMachine::unwatch_pid(@signature) end |