daemon server using perl

Neil Cherry ncherry at linuxha.com
Fri Sep 28 02:07:02 UTC 2007


Gregory P. Ennis wrote:
> Everyone,
> 
> I would like to create a daemon server that could be used like sendmail,
> dovecot etc.  I would like it to monitor a specified port for queries
> from a local network, and pass the queries to a database that is not
> mysql or postgresql, and return the results to the same port,  
> 
> I do not  have experience in C so I would prefer to use perl.  
> 
> Can anyone point me to a tutorial?

I don't have a tutorial but this should help:

# OK Here is were I need to daemonize this program. (NJC)
#
#     * Open /dev/tty and use the the TIOCNOTTY ioctl on it. See tty(4)
#       for details. Or better yet, you can just use the POSIX::setsid()
#       function, so you don't have to worry about process groups.
#     * Change directory to /
#     * Background yourself like this:

     setsid() || die "Can't start a new session: $!";
     chdir("/");
     fork && exit;

Then open your network ports and proceed to listen.

You might also want to use a search engine for "Perl daemon" you'll
find links like this:

http://search.cpan.org/~ehood/Proc-Daemon-0.03/Daemon.pm

-- 
Linux Home Automation         Neil Cherry       ncherry at linuxha.com
http://www.linuxha.com/                         Main site
http://linuxha.blogspot.com/                    My HA Blog
Author of:    	Linux Smart Homes For Dummies




More information about the users mailing list