|
From: <me...@ho...> - 2006-06-19 08:33:27
|
On Sunday 18 June 2006 15:35, Nikodemus Siivola wrote: > Currently there is no way in SBCL to kill runaway threads without > killing the whole image. > > Example: > > (defun bad () > (unwind-protect > (progn > (write-line "/i'm a little runaway!") > (loop)) > (bad))) > > (defvar *bad* (sb-thread:make-thread #'bad :name "Bad")) > > ...now good luck killing *BAD*. > > Here's a first cut in making this possible. First cut not in the > sense that I think there is anything wrong with it, but in the sense > that I haven't enough time on thinking about the interface. More of > that in another post. > > All that happens here is that the thread exit related cleanups have > been moved into HANDLE-THREAD-EXIT and handle_thread_exit on the > C-side, and instead of returning we always end up calling > pthread_exit. > > Does the implementation look reasonable to the more thread-savvy > among us? The patch looks reasonable to me. About the interface, instead of=20 THREAD-EXIT (which should be EXIT-THREAD anyway), you could undeprecate=20 DESTROY-THREAD and make it interrupt the target thread with (lambda ()=20 (handle-thread-exit thread)). I don't really like that SB-EXT:QUIT either exits the current thread or=20 the whole image depending on the current thread being the initial=20 thread, but it's understandable for backward compatibility reasons. So=20 if the contract of QUIT is to stay the same, one could hook up=20 destroy-thread to the recklessly-p branch, killing=20 the '(sb-thread:make-thread (lamba () (quit :recklessly-p t))) exits=20 the image' bug. Cheers, G=E1bor |