From: ara.t.howard@... Date: 2006-07-12T02:20:36+09:00 Subject: Re: Nuby Q: Daemonize (other materials have been read!) On Wed, 12 Jul 2006, Rogue Amateur wrote: > unknown wrote: >> On Wed, 12 Jul 2006, Rogue Amateur wrote: >> >>> [snip again] >>> >>> I tried it: >>> ./daemon.rb ./my_Script.rb >>> it dies without comment. >>> >>> running ./my_Script.rb, however, works as expected. Notions? >> >> it doesn't die - it starts the script as a daemon. check in top. >> > > > > Ok, then I'm really confused. Because the script is NOT running. > > The script in question sends data to and receives data from a socket. I > have test code written which sends data to the appropriate socket, and > receives back, and prints the result. > > When I started the listener, then daemonized the script, the listener > sat there doing nothing. ps -ef returned nothing (for the script name). > When I started the script alone, suddenly the listener has something to > do, and the ps -ef returns data. I am sure I did something wrong, I > don't doubt it a bit, but... it really doesn't look like the script is > running as a daemon. Am I using the wrong checks? Will my sockets > suddenly work differently when run as a daemon? I haven't found > anything that says that's likely so... I must be confused. > > Thank you for your quick responses. hmmm. not sure what to say. here it is spelled out a bit more: fortytwo :~ > cat `which daemon` #! /usr/bin/env ruby fork{ fork{ null = open '/dev/null', 'r+' [STDIN, STDOUT, STDERR].each{|io| io.reopen null} cmd = ARGV.join(' ') status = system cmd status ? exit : abort } exit! } fortytwo :~ > daemon sleep 42 fortytwo :~ > ps -elf |grep sleep 1 S ahoward 18615 1 0 79 0 - 715 wait 11:19 pts/50 00:00:00 ruby /home/ahoward/bin/daemon sleep 42 0 S ahoward 18616 18615 0 79 0 - 969 - 11:19 pts/50 00:00:00 sleep 42 0 R ahoward 18618 18118 0 77 0 - 96 - 11:19 pts/50 00:00:00 grep sleep regards. -a -- suffering increases your inner strength. also, the wishing for suffering makes the suffering disappear. - h.h. the 14th dali lama