From: Asterix Gallier Date: 2006-08-01T20:47:42+09:00 Subject: Re: Signaling Ruby from C/C++ now I've tried another solution. I'm sending a signal to the Rubyprocess and catch this signal with trap. - Is this solution threadsafe? I didn't know in which way ruby handles the signal exactly. - Could it be, that some Signals are getting lost because of the Handling Routine is already active? //////////////////////////////////////////////////////// // rubycode require 'RubyDriver' Signal.trap("TERM") do puts recvArray.pop.to_s end RubyDriver::startReceiver(recvThread, recvArray) //////////////////////////////////////////////////////// // c code void reciever(void* dummy) { VALUE msgsignal[2]; msgsignal[0] = rb_str_new2("TERM"); msgsignal[1] = ProcessId; while(1) { msg = recieveMessage(); // a C function wich // returns if there is // new data arrived rb_ary_push(receiverArray, msg); rb_f_kill(2, msgsignal); } } void startReceiver(VALUE pId, VALUE array) { processId = pId; receiverArray = array; hThread = (HANDLE)_beginthread( reciever, 0, NULL ); } -- Posted via http://www.ruby-forum.com/.