mirror of https://github.com/mikaku/Monitorix.git
added support to logging on the standard file descriptors #268
This commit is contained in:
parent
ef0908ca3c
commit
80217b1420
|
@ -95,13 +95,18 @@ sub HUP_handler {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub daemonize {
|
sub daemonize {
|
||||||
|
if($config{log_file}) {
|
||||||
open(STDIN, "< /dev/null") || die "Can't read /dev/null: $!";
|
open(STDIN, "< /dev/null") || die "Can't read /dev/null: $!";
|
||||||
open(STDOUT, ">> $config{log_file}") || die "Can't write to LOG: $!";
|
open(STDOUT, ">> $config{log_file}") || die "Can't write to LOG: $!";
|
||||||
|
}
|
||||||
umask(022) || die "Unable to umask 022: $!";
|
umask(022) || die "Unable to umask 022: $!";
|
||||||
exit if fork(); # parent exits
|
exit if fork(); # parent exits
|
||||||
(setsid() != -1) || die "Can't start a new session: $!";
|
(setsid() != -1) || die "Can't start a new session: $!";
|
||||||
|
|
||||||
|
if($config{log_file}) {
|
||||||
open(STDERR, ">> $config{log_file}") || die "Can't write to LOG: $!";
|
open(STDERR, ">> $config{log_file}") || die "Can't write to LOG: $!";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sub usage {
|
sub usage {
|
||||||
print(STDERR << "EOF");
|
print(STDERR << "EOF");
|
||||||
|
|
Loading…
Reference in New Issue