fork&Perl BUG

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


I modified Perl by adding sleep() in child after fork():
--------------------------------------------------------------
--- pp_sys.c.orig       Fri Apr  6 08:38:46 2001
+++ pp_sys.c    Wed Jul 30 16:23:39 2003
@@ -3700,6 +3700,8 @@
         RETSETUNDEF;
      if (!childpid) {
         /*SUPPRESS 560*/
+       /* CHILD */
+       sleep(60);
         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 */
--------------------------------------------------------------

and running test script:
--------------------------------------------------------------
bel at trash$ /usr/ports/lang/perl5.debug/work/perl-5.6.1/perl \
perlbug.pl 80000
................................................................................
Main: sum = 39952.6836460792, cnt = 80000
Child pid = 90078
Parent working...
Parent: sum = 39952.6836460792, cnt = 80000
Parent waiting a child...
Parent exiting...
Parent exiting...
--------------------------------------------------------------

Wow! Child printing "Parent exiting..."!

Its like as: kernel unblock fork() in parent before end of duplicating 
memory to child!





More information about the freebsd-sparc64 mailing list