Following is my scenario,
- I call a c function called 'subscribe' from Ruby using Ruby FFI
- The sub function runs infinitely in a while loop
- I need a way to stop this subscription from Ruby (Need to stop the c function which runs infinitely)
Ruby
require 'ffi'
module Queue
extend FFI::Library
ffi_lib FFI::Library::LIBC
attach_function :subscribe, [ :void], :void
end
Thread.new { Queue.subscribe() }
c-program
int subscribe(){
while(true){
//Do Stuff
}
}
Any thoughts? Is there a better way to manage this ?