From: Kirk Haines Date: 2002-06-14T23:36:01+09:00 Subject: Re: daemon > How do I make a script run as a deamon in ruby? I'm trying to create a > variation on fetchmail and hence I want it to run in daemon mode, when > invoked by root or so 'optioned' Here's one way: def startDaemon if (child_pid = fork) #I'm the parent. Do whatever a parent might do, such as store the #PID in a file or report it to STDOUT so that something else can #capture the info and store it. puts "PID #{child_pid}" exit end #Now, I am the child. I want to be free of my parent. Process.setsid end Call startDaemon(), and when it returns, it will be the daemonized child process that returns. Kirk Haines