2020-02-28 18:46:03 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
|
|
|
## Example in Ruby not using any signaling
|
|
|
|
|
|
|
|
counter = 0
|
|
|
|
|
2020-05-04 18:09:10 +00:00
|
|
|
def time_ns_str(t)
|
|
|
|
ns = t.nsec.to_s
|
|
|
|
(9 - ns.size).times do
|
|
|
|
ns = "0" + ns # left pad
|
|
|
|
end
|
|
|
|
t.to_i.to_s + ns
|
|
|
|
end
|
|
|
|
|
2020-02-28 18:46:03 +00:00
|
|
|
loop do
|
2020-05-04 18:09:10 +00:00
|
|
|
puts "counter_ruby count=#{counter} #{time_ns_str(Time.now)}"
|
2020-02-28 18:46:03 +00:00
|
|
|
STDOUT.flush
|
|
|
|
counter += 1
|
|
|
|
|
|
|
|
sleep 1
|
|
|
|
end
|