1 ;;;; Testing signal handling in non-lisp threads.
3 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; While most of SBCL is derived from the CMU CL system, the test
7 ;;;; files (like this one) were written from scratch after the fork
10 ;;;; This software is in the public domain and is provided with
11 ;;;; absolutely no warranty. See the COPYING and CREDITS files for
12 ;;;; more information.
14 #+(or :openbsd
:win32
(not :sb-thread
)) (invoke-restart 'run-tests
::skip-file
)
16 #+sb-thread
(sb-impl::finalizer-thread-stop
)
17 (use-package :sb-alien
)
19 (defun run (program &rest arguments
)
22 (with-output-to-string (s)
23 (setf proc
(run-program program arguments
25 (unless (zerop (process-exit-code proc
))
26 (error "Bad exit code: ~S~%Output:~% ~S"
27 (process-exit-code proc
)
32 (unless (probe-file "kill-non-lisp-thread.so")
33 (run "/bin/sh" "run-compiler.sh" "-sbcl-pic" "-sbcl-shared"
34 "-O3" "-I" "../src/runtime/"
35 "kill-non-lisp-thread.c" "-o" "kill-non-lisp-thread.so")
37 (load-shared-object (truename "kill-non-lisp-thread.so"))
39 (define-alien-routine kill-non-lisp-thread void
)
41 (with-test (:name
:kill-non-lisp-thread
43 (let ((sem (sb-thread:make-semaphore
)))
45 (sb-thread:signal-semaphore sem
))
46 (sb-thread::thread-interruptions sb-thread
:*current-thread
*))
48 ;; On sb-safepoint builds, the usual resignalling of SIGURG will
49 ;; work without problems, but the signal handler won't ordinarily
50 ;; think that there's anything to be done. Since we're poking at
51 ;; INTERRUPT-THREAD internals anyway, let's help it along.
52 (setf sb-unix
::*thruption-pending
* t
)
53 (kill-non-lisp-thread)
54 (assert (sb-thread:wait-on-semaphore sem
))))
56 (when *delete
* (delete-file "kill-non-lisp-thread.so"))