[Dev] HOWTO write a daemon

John F Davis dev@trilug.org
Fri, 24 May 2002 08:43:06 -0400


Hello Mike,

That was a good read.   I like the bit about 'and this unknown led to this
unknown etc'.  You tracked down each unknown in turn and learned a lot.  I
can identify with that.

If the original poster wants to talk about what they plan to do in more
detail, I'm sure we can all help.

Thanks

JD

"M. Mueller" <mmueller@ss7box.com>@trilug.org on 05/23/2002 11:46:14 PM

Please respond to dev@trilug.org

Sent by:    dev-admin@trilug.org


To:    dev@trilug.org
cc:
Subject:    Re: [Dev] HOWTO write a daemon



On Thursday 23 May 2002 09:56 pm, Paul D. Boyle reputedly wrote:

> Under Unix (Linux) all processes automatically open three I/O streams,
> stdin, stdout, stderr, these are often closed in a daemon process.

So, you need alternatives to these services.

I make great use of the syslogger daemon.  I had to become aware of the
klogger, or kernel logger daemon because it would generate useful
information
for me.  This led to needing an awareness of the logrotate function which
led
to needing an awareness of cron from a system point of view.  I "tail -f"
the
/var/log/messages file for long periods of time and found that logrotate
changes the file handles so that the "tail -f" goes dead so to speak.  I've
hacked a script that lets me quickly manage the tail function (script
attached). I eventually learned how to manage the /etc/syslog.conf and
syslog
calls to define new log files associated with new facilities.
Another capability that I think Brent Verner brought to my attention, and
that I have not investigated yet, is the FIFO abilities of the Linux
syslogger.  More at "man syslogd".

My daemons use AF_INET sockets for interprocess communication.  I tried
several flavors of IPC (SystemV, AF_UNIX sockets).  And there are more IPC
methods I did not try.  I've seen code that used disk files for IPC.  The
Stevens book, "UNIX Network Programming, Volume 2, Second Edition:
Interprocess Communications, Prentice Hall, 1999" was my primary resource.
I
use Python to write shell to daemon "communicators".

My intent here is to dump a bunch of ideas to the list that you can pick
through.  If there is further interest, I can provide code detail and
system
configuration detail as requested.

--
Mike Mueller
www.ss7box.com