Problems? Is your data what you think it is? | |
PerlMonks |
Re: Re: How to get a persistent daemons after exiting the session?by rob_au (Abbot) |
on Mar 11, 2003 at 22:21 UTC ( [id://242171]=note: print w/replies, xml ) | Need Help?? |
This is expected behaviour for Proc::Daemon or indeed any daemon written in line with the recommendations for daemon processes in "Advanced Programming in the Unix Environment" by W. Richard Stevens - This behaviour results from the closure of all open file handles, specifically, the line:
The best way to avoid this behaviour affecting your lock files is to acquire the lock after becoming a daemon process. If this lock acquisition fails, write to the application log and exit - This is relatively standard practice. For example, the Apache web server does something similar with regard to open a listening socket connection - The server will daemonise before opening this socket, which if fails, will write the error to the log file and exit.
I would note that there is also a race condition between the opening of the file and acquisition of the lock and that the return value of the flock function is not checked to ensure that the lock acquisition has been successful.
perl -le 'print+unpack("N",pack("B32","00000000000000000000001000111100"))'
In Section
Seekers of Perl Wisdom
|
|