[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] daemonize egg: redirect I/O?
From: |
Ozzi |
Subject: |
Re: [Chicken-users] daemonize egg: redirect I/O? |
Date: |
Tue, 30 Oct 2007 21:00:40 -0500 |
User-agent: |
Thunderbird 2.0.0.6 (Macintosh/20070728) |
Thomas Christian Chust wrote:
> I think it would suffice for daemonize to wrap the call to the daemon's
> main procedure in a dynamic-wind block and call the cleanup function
> from the exit thunk. Unless the daemon procedure terminates itself with
> a low-level _exit or by sending itself a kill signal, the cleanup code
> should then always be executed.
Ok, I think I understand what you're getting it. Unfortunately I can't get it to
work. You'll have to excuse the thrown-together quality of the code below, but
it demonstrates the problem I have. Perhaps I am just mis-using dynamic-wind, or
I have to use something besides (exit) when catching the kill signal, I'm not sure.
(use posix)
(define (silly-daemon)
(dynamic-wind
;; Before: Create our test pid file. It's empty, that's ok.
(lambda () (system "touch /tmp/test.pid"))
;; Proc: Sleep a bit.
(lambda ()
;; Exit cleanly (?) on kill.
(set-signal-handler! signal/term (lambda () (exit)))
(sleep 5))
;; After: Delete our test pid file.
(lambda () (system "rm /tmp/test.pid"))))
;; Start silly-daemon.
(let ((pid (process-fork silly-daemon)))
;; Wait long enough for silly-daemon to finish sleeping.
(sleep 7)
;; See if it deleted the pid file.
(if (file-exists? "/tmp/test.pid")
(print "Failure!")
(print "Success!")))
;; "Success!" is printed.
;; Start silly-daemon.
(let ((pid (process-fork silly-daemon)))
;; Wait a second, then...
(sleep 1)
;; ...kill silly-daemon before it finishes sleeping.
(system (format "kill ~a" pid))
;; Wait a second before...
(sleep 1)
;; ...checking to see if it deleted the pid file.
(if (file-exists? "/tmp/test.pid")
(print "Failure!")
(print "Success!")))
;; "Failure!" is printed.
Thomas Christian Chust wrote:
Ozzi wrote:
cu,
Thomas
Re: [Chicken-users] daemonize egg: redirect I/O?, Ozzi, 2007/10/26
Re: [Chicken-users] daemonize egg: redirect I/O?,
Ozzi <=
Re: [Chicken-users] daemonize egg: redirect I/O?, felix winkelmann, 2007/10/31
Re: [Chicken-users] daemonize egg: redirect I/O?, Peter Bex, 2007/10/31
Re: [Chicken-users] daemonize egg: redirect I/O?, felix winkelmann, 2007/10/31
Re: [Chicken-users] daemonize egg: redirect I/O?, Peter Bex, 2007/10/31
Re: [Chicken-users] daemonize egg: redirect I/O?, felix winkelmann, 2007/10/31
Re: [Chicken-users] daemonize egg: redirect I/O?, Peter Bex, 2007/10/31
Re: [Chicken-users] daemonize egg: redirect I/O?, felix winkelmann, 2007/10/31
Re: [Chicken-users] daemonize egg: redirect I/O?, Peter Bex, 2007/10/31
Re: [Chicken-users] daemonize egg: redirect I/O?, Thomas Christian Chust, 2007/10/31