Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

0.2: eating my own dogfood

  SB-EXT:QUIT is deprecated, call exit(3) directly since that's what we want.

  Silence compiler noise. (SB-POSIX should probably not provide
  inline-expansions for everything, especially when it just leads to noise
  like this.)

  Clarify reaping in the presence of a user-provided exit-hook.
  • Loading branch information...
commit 6e9804fcb365fdf45de091d337757416c940821c 1 parent 72e9059
@nikodemus authored
Showing with 11 additions and 4 deletions.
  1. +9 −3 daemon.lisp
  2. +1 −0  package.lisp
  3. +1 −1  sb-daemon.asd
View
12 daemon.lisp
@@ -24,6 +24,8 @@
(sb-ext:defglobal **daemon-children** nil)
(sb-ext:defglobal **daemon-lock** (sb-thread:make-mutex :name "Daemon Lock"))
+(define-alien-routine exit void (code int))
+
(defun daemonize (&key input output error (umask +default-mask+) pidfile
exit-parent (exit-hook t) (disable-debugger t)
user group
@@ -43,7 +45,8 @@ child's exit. It will be called asynchronously with three arguments: the pid
of the child, the manner of child's termination (:EXIT or :SIGNAL), and the
child's exit code or signal number that caused termination. The default exit
handler T will merely reap the child process so it will not remain in
-zombiefied state. Users wanting to reap the child manually (via eg.
+zombiefied state. Reaping will also performed automatically in presence of
+other exit hooks. Users wanting to reap the child manually (via eg.
SB-POSIX:WAITPID) must explicitly provide NIL as the EXIT-HOOK to prevent
automatic reaping.
@@ -94,7 +97,10 @@ USER and GROUP can either be specified as numeric ids, or as strings.
(declare
(type (or null string pathname) pidfile)
(type (unsigned-byte 32) umask)
- (type (or null string unsigned-byte) user))
+ (type (or null string unsigned-byte) user)
+ ;; Not much point, and silences compiler notes.
+ (notinline sb-posix:getgrnam sb-posix:getpwuid
+ sb-posix:getgrgid sb-posix:getpwnam))
;; Sanity checking.
(flet ((check-fd (fd name)
(let ((stream (symbol-value name)))
@@ -164,7 +170,7 @@ USER and GROUP can either be specified as numeric ids, or as strings.
(t
;; Parent
(when exit-parent
- (sb-ext:quit :unix-status 0 :recklessly-p t))
+ (exit 0))
(sb-posix:close in)
(sb-posix:close out)
(sb-posix:close err)
View
1  package.lisp
@@ -18,5 +18,6 @@
(defpackage :sb-daemon
(:use :cl)
+ (:import-from :sb-alien #:define-alien-routine #:void #:int)
(:export
#:daemonize))
View
2  sb-daemon.asd
@@ -17,7 +17,7 @@
;;;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(defsystem :sb-daemon
- :version "0.1"
+ :version "0.2"
:description "Process daemonization for SBCL."
:depends-on (:sb-posix)
:licence "MIT"
Please sign in to comment.
Something went wrong with that request. Please try again.