1.0.46.43: fix sb-introspect on non-threaded builds
[sbcl.git] / tests / signals.impure.lisp
index 16b9767..093bf23 100644 (file)
           (princ '*)
           (force-output))
     (terpri)))
+
+(require :sb-posix)
+
+(with-test (:name (:signal :errno))
+  (let* (saved-errno
+         (returning nil)
+         (timer (make-timer (lambda ()
+                              (sb-unix:unix-open "~!@#$%^&*[]()/\\" 0 0)
+                              (assert (= sb-unix:enoent
+                                         (sb-unix::get-errno)))
+                              (setq returning t)))))
+    (schedule-timer timer 0.2)
+    ;; Fail and set errno.
+    (sb-unix:nanosleep -1 -1)
+    (setq saved-errno (sb-unix::get-errno))
+    (assert (= saved-errno sb-posix:einval))
+    ;; Wait, but not with sleep because that will be interrupted and
+    ;; we get EINTR.
+    (loop until returning)
+    (loop repeat 1000000000)
+    (assert (= saved-errno (sb-unix::get-errno)))))
+
+(with-test (:name :handle-interactive-interrupt)
+  (assert (eq :condition
+              (handler-case
+                  (sb-thread::kill-safely
+                   (sb-thread::thread-os-thread sb-thread::*current-thread*)
+                   sb-unix:sigint)
+                (sb-sys:interactive-interrupt ()
+                  :condition)))))
+
+(with-test (:name :bug-640516)
+  ;; On Darwin interrupting a SLEEP so that it took longer than
+  ;; the requested amount caused it to hang.
+  (assert
+   (handler-case
+       (sb-ext:with-timeout 10
+         (let (to)
+           (handler-bind ((sb-ext:timeout (lambda (c)
+                                            (unless to
+                                              (setf to t)
+                                              (sleep 2)
+                                              (continue c)))))
+             (sb-ext:with-timeout 0.1 (sleep 1) t))))
+     (sb-ext:timeout ()
+       nil))))