Commit e4b59d19 authored by Gavin Brown's avatar Gavin Brown

write a pidfile for easy killing

parent 5aa03396
......@@ -54,6 +54,9 @@ files to disk.
; location to where files are written:
directory="/var/lib/dsd"
; file to write pid to
pidfile="/var/run/dsd.pid"
# SEE ALSO
- `dsd-cp`, which copies DSD data files from the DNS server to a remote server.
......
......@@ -60,6 +60,16 @@ Net::Pcap::setfilter($pcap, $filter);
$SIG{'HUP'} = \&hup_handler;
unless ($foreground) {
if (!open(PIDFILE, '>'.$config->{'dsd.pidfile'})) {
syslog(LOG_CRIT, "Error writing pid to $config->{'dsd.pidfile'}: $!");
exit(1);
} else {
print PIDFILE $$;
close(PIDFILE);
}
syslog(LOG_DEBUG, "daemonising") if ($debug);
if (fork() > 0) {
exit(0);
......@@ -282,6 +292,9 @@ Show help.
; location to where files are written:
directory="/var/lib/dsd"
; file to write pid to
pidfile="/var/run/dsd.pid"
=head1 SEE ALSO
=over
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment