Permalink
Browse files

No need for special keywords here, we can just evaluate whatever we w…

…ant on the remote process
  • Loading branch information...
1 parent 34c6a95 commit 00cc56ed7c0d67900b0d0975dd268e501f536e80 @ileitch committed Nov 26, 2010
Showing with 8 additions and 15 deletions.
  1. +5 −3 lib/hijack/output_receiver.rb
  2. +2 −11 lib/hijack/payload.rb
  3. +1 −1 lib/hijack/workspace.rb
@@ -17,8 +17,10 @@ def self.started?
end
def self.stop
- Process.kill("KILL", @pid)
- Process.waitpid(@pid)
+ if started?
+ Process.kill("KILL", @pid)
+ Process.waitpid(@pid)
+ end
end
def self.mute
@@ -40,7 +42,7 @@ def initialize(remote)
def start
setup_signal_traps
DRb.start_service(Hijack.socket_for(Process.pid), self)
- @remote.evaluate("__hijack_output_receiver_ready_#{Process.pid}")
+ @remote.evaluate("OutputCopier.start(#{Process.pid})")
DRb.thread.join
end
View
@@ -39,7 +39,7 @@ class << io
end
def self.start(pid)
- @remote = DRbObject.new(nil, 'drbunix://tmp/hijack.' + pid + '.sock')
+ @remote = DRbObject.new(nil, 'drbunix://tmp/hijack.' + pid.to_s + '.sock')
puts @remote.inspect if Hijack.debug?
class << $stdout
@@ -75,19 +75,10 @@ def write_with_copying(str)
class Evaluator
def initialize(context)
@context = context
- @file = __FILE__
end
def evaluate(rb)
- if rb =~ /__hijack_output_receiver_ready_([\\d]+)/
- OutputCopier.start($1)
- elsif rb =~ /__hijack_get_remote_file_name/
- @file
- elsif rb =~ /__hijack_exit/
- Hijack.stop
- else
- @context.instance_eval(rb)
- end
+ @context.instance_eval(rb)
end
end
@@ -15,7 +15,7 @@ def evaluate(context, statements, file = __FILE__, line = __LINE__)
if statements =~ /IRB\./
super
elsif statements.strip =~ /^(exit|quit)/
- remote.evaluate('__hijack_exit') rescue nil
+ remote.evaluate('Hijack.stop') rescue nil
super
elsif helper = Hijack::Helper.find_helper(statements)
Hijack::Helper.send(helper, remote)

0 comments on commit 00cc56e

Please sign in to comment.