Return-Path: X-Original-To: apmail-perl-dev-archive@www.apache.org Delivered-To: apmail-perl-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 696FC647E for ; Wed, 13 Jul 2011 20:09:12 +0000 (UTC) Received: (qmail 89036 invoked by uid 500); 13 Jul 2011 20:09:12 -0000 Delivered-To: apmail-perl-dev-archive@perl.apache.org Received: (qmail 88966 invoked by uid 500); 13 Jul 2011 20:09:11 -0000 Mailing-List: contact dev-help@perl.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@perl.apache.org Received: (qmail 88959 invoked by uid 99); 13 Jul 2011 20:09:10 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Jul 2011 20:09:10 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jzhao@cidc.com designates 64.206.6.10 as permitted sender) Received: from [64.206.6.10] (HELO corp-mailgate.gvcorp.grandvirtual.com) (64.206.6.10) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Jul 2011 20:09:04 +0000 Received: from corp-mailgate.gvcorp.grandvirtual.com (localhost.localdomain [127.0.0.1]) by localhost (Email Security Appliance) with SMTP id 3DB601896267_E1DFB4BB for ; Wed, 13 Jul 2011 20:08:43 +0000 (GMT) Received: from corp-exchhub.gvcorp.grandvirtual.com (corp-exchhub.gvcorp.grandvirtual.com [10.1.25.130]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (Client did not present a certificate) by corp-mailgate.gvcorp.grandvirtual.com (Sophos Email Appliance) with ESMTP id 13C31188F3A0_E1DFB4AF for ; Wed, 13 Jul 2011 20:08:42 +0000 (GMT) Received: from corp-exch.gvcorp.grandvirtual.com ([fe80::391e:f19c:4666:1cce]) by corp-exchhub.gvcorp.grandvirtual.com ([::1]) with mapi; Wed, 13 Jul 2011 16:08:41 -0400 From: Jasper Zhao To: "dev@perl.apache.org" Date: Wed, 13 Jul 2011 16:08:40 -0400 Subject: [mp2] To get APR::Pool::cleanup_for_exec officially supported Thread-Topic: [mp2] To get APR::Pool::cleanup_for_exec officially supported Thread-Index: AcxBlAZfDEsUd8itQHO/mVgDUa/ZTQ== Message-ID: <135254865ECCFC4ABE131CAC9288E9A88E0F891577@CORP-EXCH.gvcorp.grandvirtual.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Dear mod_perl2 Developers, As you know when you want to spawn a sub-process and execute an external pr= ogram you can use 'spawn_proc_prog' defined in Apache2::SubProcess. However= , if you want to spawn a sub-process and call a Perl subroutine, the sub-pr= ocess won't release the listening port therefore you cannot restart your ht= tpd daemon if the spawned process is still running. APR::Pool::cleanup_for_exec comes to rescue. It does some cleanup tasks inc= luding releasing the listening port. See the code snippet below. The method= works properly. However in the mp2 document at the link below, it says thi= s method is an unsupported API. Is it possible to get it officially support= ed? http://perl.apache.org/docs/2.0/api/APR/Pool.html#C_cleanup_for_exec_ sub fork_and_call_sub { my $pid =3D fork(); if(!defined $pid) { die("Cannot fork: $!")=20 } if($pid) { #Parent process return; } # Child goes here close STDIN; close STDOUT; open STDIN, '/dev/null'; open STDOUT,'>/dev/null'; =20 setsid; APR::Pool::cleanup_for_exec(); call_time_consuming_method(); CORE::exit(0); } Jasper --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org For additional commands, e-mail: dev-help@perl.apache.org