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 <jz...@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-unsubscr...@perl.apache.org
> For additional commands, e-mail: dev-h...@perl.apache.org
>
>

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

Reply via email to