[Openmcl-devel] creating a daemon
eblood at winkywooster.org
Mon Jul 5 11:36:51 EDT 2004
[Long post follows]
I am trying to create an application to run as a daemon at machine
startup. It is going to include allegro serve, swank, and some of my
own components. Here is my starting point:
;;; openmcl -l astest.lisp -e '(make-server)'
(eval-when (:compile-toplevel :load-toplevel :execute)
(defclass server-application (ccl::lisp-development-system)
(defmethod ccl::toplevel-function ((app server-application)
(declare (ignore init-file))
(swank:create-server :port 8001 :dont-close t)
(net.aserve:start :port 8000)
(defun make-server ()
:application-class (find-class 'server-application)
First question, is doing a process suspend on the Initial process at
the end of the toplevel-function a good thing? If I don't, the
toplevel-function will be repeatedly called. This is mostly
working--swank is opening a port, but not responding to the inital
handshake, but I am looking into that.
To go a step further, what is the best way to disassociate lisp from
the terminal? Forcibly close the 0, 1, and 2 file descriptors? Or,
is there something I can do with *terminal-io*.
I also have been playing around with forking the process:
(defun fork-test (&optional exit)
(let ((pid (#_getpid)))
(dotimes (n 5)
(format t "~A: ~A" pid n)
The two things that I observe is that the output from the parent
process is displayed over 5 seconds, and then the child process's
output follows immediately afterward. Some sort of locking? And if I
exit from the parent process, both the parent and child close. Is
this behavior also terminal related? If so, I can understand the
blocking of the child output, but why would the child process exit
when the parent process exits?
Welcome to OpenMCL Version (Beta: Darwin) 0.14.2-p1!
? 1961: 0 <-- at this point the ouput of
1961: 1 shows immediately
? (fork-test t) <-- run tests, but have the
More information about the Openmcl-devel