perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fred Moyer <f...@redhotpenguin.com>
Subject Re: [mp2] To get APR::Pool::cleanup_for_exec officially supported
Date Thu, 14 Jul 2011 20:10:23 GMT
I looked at this a while back but haven't had the tuits to follow up
on it.  Patches welcome :)

On Wed, Jul 13, 2011 at 1:08 PM, Jasper Zhao <jzhao@cidc.com> wrote:
> Dear mod_perl2 Developers,
>
> As you know when you want to spawn a sub-process and execute an external program 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-process won't release the listening port therefore
you cannot restart your httpd daemon if the spawned process is still running.
>
> APR::Pool::cleanup_for_exec comes to rescue. It does some cleanup tasks including releasing
the listening port. See the code snippet below. The method works properly. However in the
mp2 document at the link below, it says this method is an unsupported API. Is it possible
to get it officially supported?
> http://perl.apache.org/docs/2.0/api/APR/Pool.html#C_cleanup_for_exec_
>
> sub fork_and_call_sub
> {
>    my $pid = fork();
>    if(!defined $pid) {
>        die("Cannot fork: $!")
>    }
>    if($pid) {
>        #Parent process
>        return;
>    }
>     # Child goes here
>      close STDIN;
>      close STDOUT;
>      open STDIN, '/dev/null';
>      open STDOUT,'>/dev/null';
>
>      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
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message