Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm working on a old programm which uses the forks perl module.
the linux server has crashed and the server has been reinstalled.

It seems that this programm doesn't work any more.
I've reinstalled a perl distribution with the fork module. here my configuration :

[admWifi@stat1 ActivePerl-5.8]$ perl -V Summary of my perl5 (revision 5 version 8 subversion 4) configuration: Platform: osname=linux, osvers=2.2.17, archname=i686-linux-thread-multi uname='linux gimlet 2.2.17 #1 sun jun 25 09:24:41 est 2000 i686 un +known ' config_args='-ders -Dcc=gcc -Accflags=-DNO_HASH_SEED -Dusethreads +-Duseithreads -Ud_sigsetjmp -Uinstallusrbinperl -Ulocincpth= -Uloclib +pth= -Duselargefiles -Uusemallocwrap -Dinc_version_list=5.8.3/$archna +me 5.8.3 5.8.2/$archname 5.8.2 5.8.1/$archname 5.8.1 5.8.0/$archname +5.8.0 -Duseshrplib -Dprefix=/wifi/ActivePerl-5.8 -Dcf_by=ActiveState +-Dcf_email=support@ActiveState.com' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef useithreads=define usemulti +plicity=define useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS + -DNO_HASH_SEED -fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFS +ET_BITS=64', optimize='-O2', cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DNO_HASH +_SEED -fno-strict-aliasing' ccversion='', gccversion='2.95.2 20000220 (Debian GNU/Linux)', gcc +osandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=1 +2 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', + lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='gcc', ldflags ='' libpth=/lib /usr/lib /usr/local/lib libs=-lnsl -lndbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc -lpos +ix perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc -lposix libc=/lib/libc-2.1.3.so, so=so, useshrplib=true, libperl=libperl.s +o gnulibc_version='2.1.3' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E - +Wl,-rpath,/wifi/ActivePerl-5.8/lib/5.8.4/i686-linux-thread-multi/CORE +' cccdlflags='-fpic', lddlflags='-shared' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES PERL +_IMPLICIT_CONTEXT Locally applied patches: ActivePerl Build 810 22751 Update to Test.pm 1.25 21540 Fix backward-compatibility issues in if.pm Built under linux Compiled at Jun 3 2004 12:38:49 @INC: /wifi/ActivePerl-5.8/lib/5.8.4/i686-linux-thread-multi /wifi/ActivePerl-5.8/lib/5.8.4 /wifi/ActivePerl-5.8/lib/site_perl/5.8.4/i686-linux-thread-multi /wifi/ActivePerl-5.8/lib/site_perl/5.8.4 /wifi/ActivePerl-5.8/lib/site_perl

i've isolated a pb with the ping command.
when i add the line "use forks " in a little basic
programm, ping returns a bad statut :
#! /opt/ActivePerl-5.8/bin/perl use forks; use forks::shared; use Net::Ping::External qw(ping); if (! ping(host => "10.163.123.98", timeout => 2) ) { print "ping ko\n"; } else { print "ping ok \n"; } exit 1;

returns "ping ko"

#! /opt/ActivePerl-5.8/bin/perl #use forks; #use forks::shared; use Net::Ping::External qw(ping); if (! ping(host => "10.163.123.98", timeout => 2) ) { print "ping ko\n"; } else { print "ping ok \n"; } exit 1;

returns "ping ok"

Do you have any ideas about this pb ?
PS : The same little program works with the forks module on another server.

Replies are listed 'Best First'.
Re: bad ping status with the forks module
by MonkE (Hermit) on Jul 12, 2006 at 17:03 UTC
    Remember, the module you have chosen uses an external ping command -- Do you have the path to the ping command in your PATH environment variable? Have you tried the Linux ping command from a shell?

    Also, Net::Ping::external is "alpha", and thus could be very buggy. And beware: Linux support for Net::Ping::external has some restrictions.

      But he said ping works without the use forks module. The only thing I see in Net::Ping::external is that some status information is obscured. Nothing that would interact with forks.


      s//----->\t/;$~="JAPH";s//\r<$~~/;{s|~$~-|-~$~|||s |-$~~|$~~-|||s,<$~~,<~$~,,s,~$~>,$~~>,, $|=1,select$,,$,,$,,1e-1;print;redo}
Re: bad ping status with the forks module
by starbolin (Hermit) on Jul 12, 2006 at 19:02 UTC

    On the failing system, what is the output from:

    perl -e 'use forks; print system("ping -c1 localhost"),"\n$?\n";print +$! if ($?==-1)'
    I am trying to isolate the modules. This should verifiy that the problem is not in Net::Ping::External.

    perl -e 'print system("ping -c1 localhost"),"\n$?\n";print $! if ($?== +-1)' PING localhost.tan.us (127.0.0.1): 56 data bytes 64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.133 ms --- localhost.tan.us ping statistics --- 1 packets transmitted, 1 packets received, 0% packet loss round-trip min/avg/max/stddev = 0.133/0.133/0.133/0.000 ms 0 0


    s//----->\t/;$~="JAPH";s//\r<$~~/;{s|~$~-|-~$~|||s |-$~~|$~~-|||s,<$~~,<~$~,,s,~$~>,$~~>,, $|=1,select$,,$,,$,,1e-1;print;redo}
      Here the output on the failing system :

      perl -e 'use forks; print system("ping -c1 localhost"),"\n$?\n";print +$! if ($?==-1)'<br/> PING localhost.localdomain (127.0.0.1) 56(84) bytes of data. 64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=0 ttl=0 time +=0.036 ms --- localhost.localdomain ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.036/0.036/0.036/0.000 ms, pipe 2 -1 -1 No child processes

        That's what I thought. Threads is broke on your build of perl. Ping runs but system returns -1. You're going to have to recompile perl and have a look at the output from make.


        s//----->\t/;$~="JAPH";s//\r<$~~/;{s|~$~-|-~$~|||s |-$~~|$~~-|||s,<$~~,<~$~,,s,~$~>,$~~>,, $|=1,select$,,$,,$,,1e-1;print;redo}
Re: bad ping status with the forks module
by starbolin (Hermit) on Jul 15, 2006 at 06:13 UTC
    First of all, let me welcome you to Pelmonks erc_fun and thank you for registering. I stand corrected due to the kind admonishments of BrowserUk and I agree with him when he says:

    "And going by your demonstration of the failure, the problem appears to clearly lie entirely within, or as a side effect of using the Forks module,..

    Howerver I still have to desagree with him as to :

    "...and I see no way that re-building perl would have any effect whatsoever."

    Obviously there is some difference between your two systems and we still don't know what that difference is.

    One thing I noticed, your perl was built with native threads. From your original post:

    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define

    Which , at best, is redundant to the forks module and, at worst, is colliding with forks and causing your problem. (I can't confirm either way as I can't get the forks module to complete make test on my system.)

    Look, I don't know how to fix your system. You have three choices.

  • Change your code.
  • Write more tests in hopes of further isolating the problem.
  • Start swinging a hammer. i.e. rebuild perl, rebuild forks.

    To rebuild perl see Install parallel Perl on Debian
    To rebuild forks see A Guide to Installing Modules


    s//----->\t/;$~="JAPH";s//\r<$~~/;{s|~$~-|-~$~|||s |-$~~|$~~-|||s,<$~~,<~$~,,s,~$~>,$~~>,, $|=1,select$,,$,,$,,1e-1;print;redo}

      starbolin++

      However I still have to desagree with BrowserUk as to :

      That's the problem with coming in half way through a thread and not fully reading back to the beginning--you (I) am apt to miss things.

      You are right. If the machine had a non-threaded perl installed prior to the crash, (and if the The same little program works with the forks module on another server., is running a non-threaded version of perl), then that would be a good clue as to a conflict between Forks and threaded perl builds. Acquiring/building a non-threaded build of perl may well restore the function of the program.

      I think using threads, or Net::Ping 'syn' mode is a better solution long term, but that's a personal choice.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.