File: daemon.pl

package info (click to toggle)
libproc-fork-perl 0.806-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 140 kB
  • sloc: perl: 164; makefile: 2
file content (13 lines) | stat: -rw-r--r-- 388 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
use strict;
use Proc::Fork;
use POSIX;

# One-stop shopping: fork, die on error, parent process exits.
run_fork { parent { exit } };

# Other daemon initialization activities.
$SIG{INT} = $SIG{TERM} = $SIG{HUP} = $SIG{PIPE} = \&some_signal_handler;
POSIX::setsid() == -1 and die "Cannot start a new session: $!\n";
close $_ for *STDIN, *STDOUT, *STDERR;

# rest of daemon program follows