Daemon direction. Or, What do I need to watch for?

Hi,

I'm writing my first daemon application. I need to make sure I cover my bases as far as correct procedures, etc... I've tried to do my own legwork by reading as much as I could on daemonizing programs, etc... There are so many different examples, some include this but not that, etc... So, to make a short story long... I could use a little "live" help.

I've got the following criteria covered...

o Gathering of process ID's, session ID, lockfile, PID file creation and removal with conformation.
o Syslog reporting and optional -v tty output for debugging (non daemon mode).
o Signal trapping for 2, 3, and 15 with cleanup routines. Close all open files, syslog, STDIN/OUT/ERR, etc.... remove afore mentioned lock and pid files.

What else do I need to look out for?

Thanks!

change current working directory (typically "/)
reset file access creation mask
disassociate from process group
do not reacquire control terminal
...besides what you already have
see "Unix Network Programming - Stevens, chap. 2, section 2.6 (daemon processes)"

Change Directory was in there. I forgot to list it.

As far as the others. There was noting in ANY of the examples I found about those.
This is why I ask.

THANKS!!! I'll have to read up on them.

Glad I could help.
You can't go wrong with just about anything from Stevens.
He was one of the best!
And there's sample code in the book.
Andy Tanenbaum is another good Unix author to read.

---------- Post updated at 12:54 PM ---------- Previous update was at 12:45 PM ----------

one last tidbit, here's a discussion of creating a daemon in tcl/tk, with reference to the steven's book.
You can read the function to daemonize, which pretty much sums up what you'll need to do.

here's the link:
daemon