Skip to content

Commit

Permalink
make sure to kill the process
Browse files Browse the repository at this point in the history
  • Loading branch information
dsh0416 committed Feb 6, 2024
1 parent 19ece48 commit b56c2f4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/prolog_mqi/prolog_mqi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ def initialize(timeout: 5)
@process = nil
@socket = nil
@running = false

ObjectSpace.define_finalizer(self, self.class.finalize(@process))
end

def self.finalize(process)
proc { process&.kill }
end

def running?
Expand Down Expand Up @@ -99,6 +105,7 @@ def stop
@stdout.close
@stderr.close
@process.kill
@process = nil
@running = false
end
end
Expand Down

0 comments on commit b56c2f4

Please sign in to comment.