diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-03-23 21:54:19 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-03-23 21:54:19 -0700 |
commit | 494f8eb820eb22e5920baa5764660a2ac5dc2824 (patch) | |
tree | 9fd5e5b8b4de607abfc123bd71229a3902fce0bb | |
parent | a8047da6699c8dfcb281e422689c8003305768a8 (diff) | |
download | consfigurator-494f8eb820eb22e5920baa5764660a2ac5dc2824.tar.gz |
move CAN-PROBABLY-FORK to CONNECTION.FORK
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r-- | src/connection/chroot.lisp | 10 | ||||
-rw-r--r-- | src/connection/fork.lisp | 10 | ||||
-rw-r--r-- | src/package.lisp | 8 |
3 files changed, 16 insertions, 12 deletions
diff --git a/src/connection/chroot.lisp b/src/connection/chroot.lisp index df6b85b..f518acf 100644 --- a/src/connection/chroot.lisp +++ b/src/connection/chroot.lisp @@ -23,16 +23,6 @@ (defun can-chroot () (zerop (foreign-funcall "geteuid" :int))) -(defun can-probably-fork () - "Return nil if we can detect other running threads, and the Lisp -implementation is known not to support forking when there are other threads. -A return value other than nil indicates only that we couldn't detect -circumstances in which it is known that we cannot fork, not that we are sure -we can fork -- a thread might be only partly initialised at the time we check, -for example, such that we don't see it." - (and - #+sbcl (> 2 (length (sb-thread:list-all-threads))))) - (defmethod establish-connection ((type (eql :chroot)) remaining &key into) (establish-connection (if (and (lisp-connection-p) (can-chroot) diff --git a/src/connection/fork.lisp b/src/connection/fork.lisp index 702ca96..6a4ad0c 100644 --- a/src/connection/fork.lisp +++ b/src/connection/fork.lisp @@ -31,6 +31,16 @@ ;; (values PID EXIT-STATUS), as SB-POSIX:WAITPID does #+sbcl (sb-posix:waitpid pid options)) +(defun can-probably-fork () + "Return nil if we can detect other running threads, and the Lisp +implementation is known not to support forking when there are other threads. +A return value other than nil indicates only that we couldn't detect +circumstances in which it is known that we cannot fork, not that we are sure +we can fork -- a thread might be only partly initialised at the time we check, +for example, such that we don't see it." + (and + #+sbcl (> 2 (length (sb-thread:list-all-threads))))) + (defmacro with-fork-connection ((remaining) &body forms) `(progn (unless (lisp-connection-p) diff --git a/src/package.lisp b/src/package.lisp index ede88f2..4e69ff3 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -277,7 +277,8 @@ (defpackage :consfigurator.connection.fork (:use #:cl #:consfigurator) - (:export #:with-fork-connection)) + (:export #:with-fork-connection + #:can-probably-fork)) (defpackage :consfigurator.connection.ssh (:use #:cl @@ -296,7 +297,10 @@ (:export #:local-connection)) (defpackage :consfigurator.connection.chroot - (:use #:cl #:consfigurator #:cffi)) + (:use #:cl + #:consfigurator + #:consfigurator.connection.fork + #:cffi)) (defpackage :consfigurator.connection.chroot.fork (:use #:cl |