Trap ctrl-c and exit nicely

Hello,

I want to trap a ctrl-c, wait for any http request to finish,and then
exit the program. I know I can Kernel#trap , but not sure how to wait
for the network operation to end. Do I need to perform the network
operation in a thread?

On Dec 17, 2005, at 11:32 AM, Jim wrote:

Hello,

I want to trap a ctrl-c, wait for any http request to finish,and then
exit the program. I know I can Kernel#trap , but not sure how to wait
for the network operation to end. Do I need to perform the network
operation in a thread?

interrupted = false

trap(“INT”) { interrupted = true }

do HTTP request

if interrupted
exit
end

rest of program