From: Kyle Schmitt Date: 2009-02-18T08:04:41+09:00 Subject: a little daemon daemonizes, but hangs the logout I needed a little daemon thisafternoon, so I wrote one in ruby using fork and Process.detach. It's working ok I suppose, except that when I logout, it hangs, and I have to kill my session. It's a little annoying, to say the least. Anyone know a better way of doing this? Thanks, code follows --Kyle #!/usr/bin/ruby #I've chopped out the bulk of the code in the Monitor class, since it's not really relevant, and not terribly clean either. require 'net/smtp' class Monitor def _setup_signals() death_signals=%w{KILL QUIT STOP TERM EXIT} Signal.trap("HUP") do _setup_logfile() _setup_ignores() end death_signals.each do |signal| Signal.trap(signal) do log("Caught #{signal} signal") @running=false end end end def loop while @running end end end pid = fork do m=Monitor.new m.loop end Process.detach(pid)