I have a perl script which i am running in daemon mode with the following code.
Proc::Daemon::Init()
# Anonymous subroutine.
my $sub = sub {
# Call to the function which opens the filehandle
my $content = RandomPackage::GetContent({ $args});
}
# Forking
Proc::ForkAndForget->({JOB => $sub });
The RandomPackage::GetContent has the following definition.
use File::Temp;
sub GetContent {
my ($args) = @_;
my ($filehandle, $filename) = File::Temp::tempfile();
open $filehandle, ">", $filename or "cant open the filehandle";
<Some operations>
return ;
}
While running the script in daemon mode, I get the error cant open the filehandle. Any help is appreciated.