#26 ForkOnAccept example reaper for Win32


Using SOAP/Transport/HTTP/Daemon/ForkOnAccept.pm
from 0.55 on a PC under perl 5.8.0 (yes perl emulates
in the Win32 environment I think since 5.6.x) we found that
eventually the fork() call starts failing quietly. By
I mean the $pid it returns is undef. While I don't know the
mechanics behind the scenes my guess is it has a table of
processes it keeps just like unix does and this is filling
up. Normally in unix you must reap your terminated child
processes with a wait() or waitpid() call or your process
table will eventually be overrun by zombie processes ("Need
more brains..."). Anyway to do this in unix you typically
add a reaper as a signal handler $SIG{CHLD} = \&reaper;

We use our server in unix and Win32, and while we see no
compiler or runtime complaints, we're finding the reaper is
not being called in he Win32 environment. Thus eventually
the fork() starts returning undef and our clients get a 500
error because their requests go unanswered. We solved this
by simply adding a reaping loop to ForkOnAccept.pm so it
cleans up after any previous requests that have completed.

Submitted for possible addition to the examples directory
is the attached ReapForkOnAccept.pm. I also aded a
print to STDERR in the event the fork does fail. You
might do something else here because the server will
continue happily accepting connections but if fork()
undef, they won't be serviced.


  • sydd

    sydd - 2005-02-25

    Alternate to examples/SOAP/Transport/HTTP/Daemon/ForkOnAccept.pm

  • Martin Kutter

    Martin Kutter - 2008-09-21
    • labels: 532006 -->
    • milestone: 250889 -->
    • assigned_to: byrnereese --> nobody

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks