Dynamic space relocation, part 1 of 2
[sbcl.git] / tests / kill-non-lisp-thread.impure.lisp
blobf7f88fd9b9068ac082c1dfc2a4398ad197aaf300
1 ;;;; Testing signal handling in non-lisp threads.
3 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; more information.
5 ;;;;
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
8 ;;;; from CMU CL.
9 ;;;;
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 :win32 (not :sb-thread))
15 (sb-ext:exit :code 104)
17 (use-package :sb-alien)
19 (defun run (program &rest arguments)
20 (let* ((proc nil)
21 (output
22 (with-output-to-string (s)
23 (setf proc (run-program program arguments
24 :output s)))))
25 (unless (zerop (process-exit-code proc))
26 (error "Bad exit code: ~S~%Output:~% ~S"
27 (process-exit-code proc)
28 output))
29 output))
31 (run "/bin/sh" "run-compiler.sh" "-sbcl-pic" "-sbcl-shared"
32 "-O3" "-I" "../src/runtime/"
33 "kill-non-lisp-thread.c" "-o" "kill-non-lisp-thread.so")
35 (load-shared-object (truename "kill-non-lisp-thread.so"))
37 (define-alien-routine kill-non-lisp-thread void)
39 (with-test (:name :kill-non-lisp-thread)
40 (let ((receivedp nil))
41 (push (lambda ()
42 (setq receivedp t))
43 (sb-thread::thread-interruptions sb-thread:*current-thread*))
44 #+sb-thruption
45 ;; On sb-thruption builds, the usual resignalling of SIGPIPE will
46 ;; work without problems, but the signal handler won't ordinarily
47 ;; think that there's anything to be done. Since we're poking at
48 ;; INTERRUPT-THREAD internals anyway, let's help it along.
49 (setf sb-unix::*thruption-pending* t)
50 (kill-non-lisp-thread)
51 (sleep 1)
52 (assert receivedp)))
54 (delete-file "kill-non-lisp-thread.so")