jrottman
Programmer
- Jun 17, 2005
- 47
I am using posix to create a daemon of the perl app that I am working on. However, I have run into a small snag.
I have broken each of my sections into separate perl files and I have used require to import the separate perl files (not sure if this is the right way, but still learning here).
Any way, when testing my application, I get few errors that I am unsure of and need a little help figuring them out. Any help with this is greatly appreciated.
To start off with here are the errors that I receive.
Useless use of a variable in void context at ./main.pl line 8.
Name "daemon::daemonize" used only once: possible typo at ./main.pl line 8.
Name "datasource::emailHost" used only once: possible typo at ./main.pl line 11.
Unquoted string "setsid" may clash with future reserved word at daemon.pl line 13.
Bareword found in conditional at daemon.pl line 13.
And here is my code.
Main.pl -
#!/usr/bin/perl -w
require "daemon.pl";
require "datasource.pl";
#require "mail.pl";
package main; #Package Declaration
$daemon::daemonize;
while(1){
sleep(20);
print "$datasource::emailHost \n";
#$mail::chkMail;
}
daemon.pl-
#!/usr/bin/perl -w
# Purpose: Creates Perl Daemon for given datasource
use POSIX qw(setsid);
package daemon; #package delaration
sub daemonize{
defined(my $pid = fork)
or die "Can't fork: $!";
exit if $pid;
setsid
or die "Can't start a new session: $!";
}
1;
I have broken each of my sections into separate perl files and I have used require to import the separate perl files (not sure if this is the right way, but still learning here).
Any way, when testing my application, I get few errors that I am unsure of and need a little help figuring them out. Any help with this is greatly appreciated.
To start off with here are the errors that I receive.
Useless use of a variable in void context at ./main.pl line 8.
Name "daemon::daemonize" used only once: possible typo at ./main.pl line 8.
Name "datasource::emailHost" used only once: possible typo at ./main.pl line 11.
Unquoted string "setsid" may clash with future reserved word at daemon.pl line 13.
Bareword found in conditional at daemon.pl line 13.
And here is my code.
Main.pl -
#!/usr/bin/perl -w
require "daemon.pl";
require "datasource.pl";
#require "mail.pl";
package main; #Package Declaration
$daemon::daemonize;
while(1){
sleep(20);
print "$datasource::emailHost \n";
#$mail::chkMail;
}
daemon.pl-
#!/usr/bin/perl -w
# Purpose: Creates Perl Daemon for given datasource
use POSIX qw(setsid);
package daemon; #package delaration
sub daemonize{
defined(my $pid = fork)
or die "Can't fork: $!";
exit if $pid;
setsid
or die "Can't start a new session: $!";
}
1;