fork&Perl BUG

Andrew Belashov bel at orel.ru
Wed Jul 30 06:25:49 PDT 2003


I modified Perl by adding sleep(10) in parent after fork():
---------------------------------------------------------------------
--- pp_sys.c.orig       Fri Apr  6 08:38:46 2001
+++ pp_sys.c    Wed Jul 30 17:17:50 2003
@@ -3703,6 +3703,9 @@
         if ((tmpgv = gv_fetchpv("$", TRUE, SVt_PV)))
             sv_setiv(GvSV(tmpgv), (IV)PerlProc_getpid());
         hv_clear(PL_pidstatus); /* no kids, so don't wait for 'em */
+    } else {
+       /* PARENT */
+       sleep(10);
      }
      PUSHi(childpid);
      RETURN;
---------------------------------------------------------------------

and my test script working OK!!!
---------------------------------------------------------------------
(gdb) run perlbug.pl 80000
Starting program: /usr/ports/lang/perl5.debug/work/perl-5.6.1/perl 
perlbug.pl 80000
................................................................................
Main: sum = 39977.1619376211, cnt = 80000
Child working...
Child: sum = 39977.1619376211, cnt = 80000
Child exiting...
Child pid = 92042
Parent working...
Parent: sum = 39977.1619376211, cnt = 80000
Parent waiting a child...
Parent exiting...
---------------------------------------------------------------------

IMHO, it is bug in fork(2).



More information about the freebsd-sparc64 mailing list