in reply to
Perl Daemon Calling a script
A few notes in no particular order:
- I'd suggest redirecting your output to a scratch file while debugging, just in case the daemonized and/or shell script emits some errors that might help you along. You can use /dev/null after you have it properly demonified.
- Should you rewrite the shell script in perl? That depends: If the script is tiny and easy to convert, then I'd do so. If it's large it may not be worth the hassle. If you like, you might write a couple of chunks of it in perl, and call that from the shell script, and as you maintain it, you can suck more of the shell script into perl as makes sense. For example, I can never remember sed well enough to use it, so I just use perl for all my sed jobs.
- It looks like you may be removing $PID_FILENAME too soon. It appears that when you do the "detach terminal" bit, after the fork, it'll get dropped. You might want to add your signal handler after you've achieved complete deemonification.
Note: Yes, the entire reason for this post was so I could write a couple goofy variations on the word 'daemon'. I had a couple other variations, but forgot 'em before I found a place to put 'em.
When your only tool is a hammer, all problems look like your thumb.