Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl and daemonize

Status
Not open for further replies.

bdw238

MIS
Joined
Dec 15, 2005
Messages
52
Location
GB
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

 
A process is not going to know where a signal came from and therefore could not know where to send the output.
If you decide on where you want the output to go then maybe we can help.


Trojan.
 
Hello,

TrojanWarBlade,

Your correct thinking about now. I going to have send the process status information to a file using perl open function!

Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top