Re: exec and detach a subprocess

[prev] [thread] [next] [Date index for 2005/02/22]

From: Stas Bekman
Subject: Re: exec and detach a subprocess
Date: 01:58 on 22 Feb 2005
Igor wrote:
[...]
> Without the additional fork in "exit if fork() > 0;", background
> scripts which are started from exec(...) are killed when request is
> complete. Without the additional fork(), the PID for the bg process
> will be the same as for the "exec_helper.pl" script (since "exec" is
> used). Apache (apr?) knows this PID and it looks like it sends it a
> SIGKILL signal at request cleanup phase. I was not able trap other
> signals.

Actually we (mp2) have an almost complete control over it. The 
spawn_proc_prog was at some point modeled after mod_cgi. How about this patch:

Index: xs/Apache/SubProcess/Apache__SubProcess.h
===================================================================
--- xs/Apache/SubProcess/Apache__SubProcess.h   (revision 154417)
+++ xs/Apache/SubProcess/Apache__SubProcess.h   (working copy)
@@ -90,7 +90,7 @@
          return rc;
      }

-    apr_pool_note_subprocess(p, procnew, APR_KILL_AFTER_TIMEOUT);
+    /*apr_pool_note_subprocess(p, procnew, APR_KILL_AFTER_TIMEOUT);*/

      if (!(*script_in = procnew->in)) {
          Perl_croak(aTHX_ "broken program-in stream");

Normally it's a goodness for processes that need to run while Apache is 
running. However in your case another fork is a waste, so if the above 
works, we should call it unless an argument was passed not to call it.

        -- 
        __________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@xxxxxx.xxx http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

(message missing)

exec and detach a subprocess
Igor Shevchenko 23:25 on 18 Feb 2005

Re: exec and detach a subprocess
Stas Bekman 01:06 on 19 Feb 2005

Re: exec and detach a subprocess
Igor Shevchenko 14:29 on 19 Feb 2005

Re: exec and detach a subprocess
Stas Bekman 16:44 on 19 Feb 2005

Re: exec and detach a subprocess
Igor Shevchenko 17:02 on 19 Feb 2005

Re: exec and detach a subprocess
Stas Bekman 17:06 on 19 Feb 2005

Re: exec and detach a subprocess
Stas Bekman 16:51 on 19 Feb 2005

Re: exec and detach a subprocess
Igor Shevchenko 17:18 on 19 Feb 2005

Re: exec and detach a subprocess
Stas Bekman 17:26 on 19 Feb 2005

Re: exec and detach a subprocess
Igor Shevchenko 14:20 on 20 Feb 2005

Re: exec and detach a subprocess
Stas Bekman 01:16 on 21 Feb 2005

Re: exec and detach a subprocess
Igor 08:28 on 21 Feb 2005

Re: exec and detach a subprocess
Stas Bekman 01:58 on 22 Feb 2005

Generated at 22:43 on 24 Feb 2005 by mariachi v0.52