diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-07-18 22:33:02 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-07-24 09:39:07 -0700 |
commit | 50915cdb6080aff3f0c29a369efd29aa5e47e5f2 (patch) | |
tree | 059f1a1542c3d0522c1579cf734b3ceda312f162 /src/util.lisp | |
parent | f4e9170e73cb4bcfa7328422b4ff4f72d1339dd0 (diff) | |
download | consfigurator-50915cdb6080aff3f0c29a369efd29aa5e47e5f2.tar.gz |
UNWIND-PROTECT-IN-PARENT -> UNWIND-PROTECT
No longer needed thanks to f4e9170e73cb4bcfa7328422b4ff4f72d1339dd0.
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/util.lisp')
-rw-r--r-- | src/util.lisp | 27 |
1 files changed, 1 insertions, 26 deletions
diff --git a/src/util.lisp b/src/util.lisp index 5524188..2e48bce 100644 --- a/src/util.lisp +++ b/src/util.lisp @@ -507,31 +507,6 @@ previous output." ;;;; Forking utilities -(define-condition in-child-process () ()) - -(defmacro unwind-protect-in-parent (protected &body cleanup) - "Like UNWIND-PROTECT, but with a mechanism to cancel the execution of CLEANUP -in child processes resulting from calls to fork(2) during the execution of -PROTECTED. This means that CLEANUP won't get executed on both sides of the -fork, but only in the parent. - -For this to work, after fork(2), the child process must call -CANCEL-UNWIND-PROTECT-IN-PARENT-CLEANUP, which will affect all enclosing uses -of this macro." - (with-gensyms (cancelled) - `(let (,cancelled) - (unwind-protect - (handler-bind ((in-child-process (lambda (c) - (declare (ignore c)) - (setq ,cancelled t)))) - ,protected) - (unless ,cancelled ,@cleanup))))) - -(defun cancel-unwind-protect-in-parent-cleanup () - "Cancel the CLEANUP forms in all enclosing uses of UNWIND-PROTECT-IN-PARENT. -Should be called soon after fork(2) in child processes." - (signal 'in-child-process)) - ;;; Use only implementation-specific fork, waitpid etc. calls to avoid thread ;;; woes. Things like chroot(2) and setuid(2), however, should be okay. @@ -653,7 +628,7 @@ Does not currently establish a PAM session." `(let* ((,before (and (file-exists-p ,file) (read-file-string ,file))) (,data (and ,before (plusp (length ,before)) (safe-read-from-string ,before)))) - (unwind-protect-in-parent (progn ,@forms) + (unwind-protect (progn ,@forms) (with-open-file (stream ,file :direction :output :if-exists :supersede) (with-standard-io-syntax |