I am writing perl daemonize script, using the below function to daemonize the process
sub daemonize1 {
chdir '/' or die "Can't chdir to /: $!";
open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
open STDOUT, '>>/dev/null' or die "Can't write to /dev/null: $!";
open STDERR, '>>/dev/null' or die "Can't write to /dev/null: $!";
defined(my $pid = fork) or die "Can't fork: $!";
exit if $pid;
setsid or die "Can't start a new session: $!";
umask 0;
my $date =
log_message("\nFTP Publisher started at",0);
}
You will notice, as per standard I have redirected STDOUT, STDERR, STDIN to /dev/null.
However, I want to send USR1 signal to the program from console / tty session so that I display the program status to the user, then redirect back to /dev/null.
How do I do this?
Thanks
Brian
sub daemonize1 {
chdir '/' or die "Can't chdir to /: $!";
open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
open STDOUT, '>>/dev/null' or die "Can't write to /dev/null: $!";
open STDERR, '>>/dev/null' or die "Can't write to /dev/null: $!";
defined(my $pid = fork) or die "Can't fork: $!";
exit if $pid;
setsid or die "Can't start a new session: $!";
umask 0;
my $date =
log_message("\nFTP Publisher started at",0);
}
You will notice, as per standard I have redirected STDOUT, STDERR, STDIN to /dev/null.
However, I want to send USR1 signal to the program from console / tty session so that I display the program status to the user, then redirect back to /dev/null.
How do I do this?
Thanks
Brian