Igor Shevchenko wrote:
Hi all,
How can I launch a subprocess and have it completely detached from the
mod_perl2/apache2 environment ? All file descriptors closed, not in a process
group, etc.
I was trying to do it like this:
sub safe_exec {
return if fork() > 0;
# close all descriptors
foreach my $fd ( 0, 3..1023 ) { close $fd }
exec ( @_ );
CORE::exit;
}
Unfortunately this doesn't close sockets which are listening on ports 80 and
443. Tried it like this:
* start apache
* run bg process from web page / script
* stop apache
* "ps auxww|grep httpd" doesn't show any httpd process running,
"netstat -lp|grep http" shows ports 80 and 443, listening in a perl process
(my background script)
Because of this, apache fails to restart when any of background processes are
running. How do I close all file descriptors and sockets ?
(this is linux 2.6)
Igor, the techniques explained here don't work?
http://perl.apache.org/docs/1.0/guide/performance.html#Forking_and_Executing_Subprocesses_from_mod_perl
What about?
$r->spawn_proc_prog
http://perl.apache.org/docs/2.0/api/Apache/SubProcess.html#C_spawn_proc_prog_
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com