Problem with fork on some RHEL servers

Discussion in 'Perl Misc' started by Dennis, Mar 9, 2012.

  1. Dennis

    Dennis Guest

    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
     
    Dennis, Mar 9, 2012
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. S P Arif Sahari Wibowo

    Running Eclipse from RHAPS2 on RHEL-4

    S P Arif Sahari Wibowo, Nov 24, 2005, in forum: Java
    Replies:
    8
    Views:
    578
    S P Arif Sahari Wibowo
    Nov 28, 2005
  2. benchline

    Jpype on RHEL v3

    benchline, Apr 7, 2006, in forum: Python
    Replies:
    1
    Views:
    1,898
    benchline
    Apr 7, 2006
  3. Christopher Taylor

    Compile for 64bit RHEL

    Christopher Taylor, Oct 19, 2006, in forum: Python
    Replies:
    1
    Views:
    272
    MrJean1
    Oct 19, 2006
  4. Replies:
    4
    Views:
    381
    Keith Thompson
    Jun 6, 2007
  5. Eric Snow

    os.fork and pty.fork

    Eric Snow, Jan 8, 2009, in forum: Python
    Replies:
    0
    Views:
    575
    Eric Snow
    Jan 8, 2009
Loading...

Share This Page