Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use IO.popen because JRuby doesn't have fork (and IO.popen does what …

…I need anyway
  • Loading branch information...
commit 92cc8d1b428de5b11fef9801510409d1f939860d 1 parent 2f99858
@jordansissel jordansissel authored
Showing with 14 additions and 18 deletions.
  1. +8 −12 spec/longrun_spec.rb
  2. +6 −6 spec/lumberjack_spec.rb
View
20 spec/longrun_spec.rb
@@ -20,14 +20,10 @@
:ssl_certificate => @ssl_cert.path,
:ssl_key => @ssl_key.path
)
- reader, @writer = IO::pipe
- @lumberjack_pid = fork do
- @writer.close
- $stdin.reopen(reader)
- exec("build/bin/lumberjack --host localhost --port #{@server.port} " \
- "--ssl-ca-path #{@ssl_cert.path} -")
- end
- reader.close
+ @lumberjack = IO.popen("build/bin/lumberjack --host localhost " \
+ "--port #{@server.port} " \
+ "--ssl-ca-path #{@ssl_cert.path} -",
+ "r+")
@event_queue = Queue.new
@server_thread = Thread.new do
@@ -41,8 +37,8 @@
@ssl_cert.close
@ssl_key.close
@ssl_csr.close
- Process::kill("KILL", @lumberjack_pid)
- Process::wait(@lumberjack_pid)
+ Process::kill("KILL", @lumberjack.pid)
+ Process::wait(@lumberjack.pid)
end
it "should follow stdin" do
@@ -50,12 +46,12 @@
message = "hello world foo bar baz fizz=lkjwelfkj"
Thread.new do
count.times do |i|
- @writer.puts("#{message} #{i}")
+ @lumberjack.puts("#{message} #{i}")
# random sleep 0.01% of the time
sleep(rand) if rand < 0.0001
end
- @writer.close
+ @lumberjack.close
end
# Now verify that we have all the data and in the correct order.
View
12 spec/lumberjack_spec.rb
@@ -21,10 +21,10 @@
:ssl_certificate => @ssl_cert.path,
:ssl_key => @ssl_key.path
)
- @lumberjack_pid = fork do
- exec("build/bin/lumberjack --host localhost --port #{@server.port} " \
- "--ssl-ca-path #{@ssl_cert.path} #{@file.path}")
- end
+ @lumberjack = IO.popen("build/bin/lumberjack --host localhost " \
+ "--port #{@server.port} " \
+ "--ssl-ca-path #{@ssl_cert.path} #{@file.path}",
+ "r")
@event_queue = Queue.new
@server_thread = Thread.new do
@@ -39,8 +39,8 @@
@ssl_cert.close
@ssl_key.close
@ssl_csr.close
- Process::kill("KILL", @lumberjack_pid)
- Process::wait(@lumberjack_pid)
+ Process::kill("KILL", @lumberjack.pid)
+ Process::wait(@lumberjack.pid)
end
it "should follow a file and emit lines as events" do
Please sign in to comment.
Something went wrong with that request. Please try again.