Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
s7nfo committed Jul 4, 2024
1 parent 8a875c1 commit defe57b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
8 changes: 0 additions & 8 deletions ruby/lib/tracer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,9 @@ def self.trace(timeout = 10, &block)
trace_file = Tempfile.new('cirron')
trace_file.close
parent_pid = Process.pid
puts parent_pid
cmd = "strace --quiet=attach,exit -f -T -ttt -o #{trace_file.path} -p #{parent_pid}"

strace_proc = spawn(cmd, :out => "/dev/null", :err => "/dev/null")
puts strace_proc

deadline = Time.now + timeout
begin
Expand All @@ -124,18 +122,12 @@ def self.trace(timeout = 10, &block)
end
end

puts block_given?
sleep 1

yield if block_given?
ensure
sleep 1
Process.kill('INT', strace_proc) rescue nil
Process.wait(strace_proc) rescue nil
end

puts "WAT\n"
puts trace_file.path
result = File.open(trace_file.path, 'r') do |file|
parse_strace(file)
end
Expand Down
6 changes: 1 addition & 5 deletions ruby/tests/tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
class TestCirron < Minitest::Test
def test_tracer
t = Cirron::Tracer.trace do
Tempfile.create('test') do |f|
puts "block\n"
f.write('test')
sleep 0.1
end
sleep 0.1
end

puts t
Expand Down

0 comments on commit defe57b

Please sign in to comment.