Problem with fork on some RHEL servers


D

Dennis

Hi,

This is really not a Perl issue or Perl module issue per se, but doing
this in Perl and not sure where to turn. But the issue below works just
fine on one RHEL server but crashes on another RHEL server.

Using Proc::Daemon and Log::Handler in a Perl script and Perl module,
when the module tries to write to its log file the forked process crashes.

The server this works on is Linux 2.6.18-274.el5, which is a VM.
The server it doesn't is Linux 2.6.18-194.el5, which is physical
hardware. But this also works on
Linux 2.6.30.10-105.2.23.fc11.i686.PAE, which is physical hardware.

The complete setup is as follows and I think I've stripped it down to
the bare minimum that works on one server but not the other. Also, if I
don't use Proc::Daemon and code a fork process the results are the same.

I just can't figure out what is different between the two servers, or
what I should be looking for.

Thanks

Dennis

########### .testDaemon.pl #############
#!/usr/bin/perl

use strict;
use warnings;

use Proc::Daemon;
use Data::Dumper;
use Log::Handler;

use lib '/opt/sdo/lib/handlers';
use Stuff::MonitorStuffFiles;

my $stuffMonitor = Stuff::MonitorStuffFiles->new();

my $mainLog = Log::Handler->new(
config => '/opt/sdo/lib/handlers/Stuff/loggers/logger.conf',
section => 'monitorStuffFiles'
);

$mainLog->error( Dumper($stuffMonitor) );

Proc::Daemon::Init( {
child_STDOUT => '/tmp/daemon.out',
child_STDERR => '/tmp/daemon.out'
} );

my $log = Log::Handler->new(
config => '/opt/sdo/lib/handlers/Stuff/loggers/logger.conf',
section => 'monitorStuffFiles'
);

$log->info("Starting monitoring...");

while (1) {
my @fileList = glob("/opt/sdo/nas/Test/*xml");
for my $file (@fileList) {
$log->info("File: $file");
$stuffMonitor->processFile($file);
}
sleep 5;
}

########### Stuff:MonitorStuffFiles.pm ###########
package Stuff::MonitorStuffFiles;

use strict;
use warnings;

use Data::Dumper;
use Log::Handler;

my $log = Log::Handler->new(
config => '/opt/sdo/lib/handlers/Stuff/loggers/logger.conf',
section => 'monitorStuffFiles'
);

sub new {
my $class = shift;
my $self = {};

bless $self, $class;
return $self;
}

sub processFile {
my ( $self, $file ) = @_;

$log->info("Got file: $file"); # <==commenting out this line
# then the daemon runs OK.
return;

}

1;

######### logger conf file ############
<monitorStuffFiles>
<file>
mode = append
permissions = 0666
maxlevel = debug
minlevel = emergency
utf8 = 1
timeformat = %Y%m%d.%H%M%S
message_layout = %T [%L] > %p:%l - %m
filename = /opt/sdo/lib/handlers/Stuff/stuff.log
</file>
</monitorStuffFiles>

What is in /tmp/daemon.out ------

Log::Handler::Output: unable to print to logfile: Bad file descriptor at
/usr/lib/perl5/site_perl/5.8.8/Log/Handler/Levels.pm line 212
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top