At 09:01 AM 6/20/02 +0200, Damir Horvat wrote:
>Hi!
>
>I've been trying to keep this thingie going with this sub, but it dies on
>me every now and then ...
>
>or, does someone have a full-featured daemon code|sub?
% perldoc -q daemon
Found in /opt/perl/lib/5.6.1/pod/perlfaq8.pod
How do I fork a daemon process?
If by daemon process you mean one that's detached
(disassociated from its tty), then the following
process is reported to work on most Unixish systems.
Non-Unix users should check their Your_OS::Process
module for other solutions.
o Open /dev/tty and use 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.
o Change directory to /
o Reopen STDIN, STDOUT, and STDERR so they're not
connected to the old tty.
o Background yourself like this:
fork && exit;
The Proc::Daemon module, available from CPAN,
provides a function to perform these actions for
you.
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]