Making a daemon

X

Xaonon

I have a signature generation program that I want to have become a daemon
and write to a named pipe. Currently, the section of code responsible for
daemonizing it looks something like this:

if ( my $pid = fork ) { print "$0: forked to PID $pid\n"; exit; }
elsif( not defined $pid ) { die "$0: fork failed: $!\n"; }
else { setsid; }

So far it works, but there's always the possibility that it could be screwed
up by something I haven't considered. This is the first Perl program I've
written as a daemon and I want to make sure that I've done it correctly. Is
there anything more that I need to have it do?

The entire program is available for consideration at:

http://xaonon.dyndns.org/about/randsig.pl

Please let me know if I've done anything stupid, as well. Thanks.
 
G

Greg Bacon

: I have a signature generation program that I want to have become a daemon
: and write to a named pipe. [...]

The FAQ covers this: "How do I fork a daemon process?" in Section 8.

Greg, uses a random signature generator too
 
X

Xaonon

Greg Bacon said:
: I have a signature generation program that I want to have become a daemon
: and write to a named pipe. [...]

The FAQ covers this: "How do I fork a daemon process?" in Section 8.

Whoops, must've missed that one. Proc::Daemon does just what I want.
Thanks for the pointer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,121
Messages
2,570,712
Members
47,283
Latest member
hopkins1988

Latest Threads

Top