You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Victor Danilchenko <vi...@askonline.net> on 2008/12/04 22:06:52 UTC

Help -- how can I make the Apache process die at the end of the request?

	I need to do it forcibly, no matter what happens during the request. I 
have to slightly relax security constraints to call an unusual 
subrequest, and since I cannot guarantee that the cleanup code will be 
reached (what if the subrequest is terminated by the client, or dies on 
a bug?), I figure my best bet it to make sure that at the end of the 
request execution, the current apache process dies so that a new one can 
be spawned. 'kill $$' is obviously inadequate.

	Does anyone have any idea how this can be achieved? perhaps utilizing 
MaxRequestsPerChild somehow, I could trick the parent process into 
terminating this one after the request completes? or is there some 
mod_perl feature which tells mod_perl to not re-use the perl runtime in 
a given process?

	Any help and/or ideas are much appreciated. Thanks in advance.

-- 
	Victor Danilchenko
	Senior Software Engineer, AskOnline.net
	victor@askonline.net - 617-273-0119

Re: Help -- how can I make the Apache process die at the end of the request?

Posted by Victor Danilchenko <vi...@askonline.net>.
Adam Prime wrote:
> Victor Danilchenko wrote:
>>     I need to do it forcibly, no matter what happens during the 
>> request. I have to slightly relax security constraints to call an 
>> unusual subrequest, and since I cannot guarantee that the cleanup code 
>> will be reached (what if the subrequest is terminated by the client, 
>> or dies on a bug?), I figure my best bet it to make sure that at the 
>> end of the request execution, the current apache process dies so that 
>> a new one can be spawned. 'kill $$' is obviously inadequate.
>>
>>     Does anyone have any idea how this can be achieved? perhaps 
>> utilizing MaxRequestsPerChild somehow, I could trick the parent 
>> process into terminating this one after the request completes? or is 
>> there some mod_perl feature which tells mod_perl to not re-use the 
>> perl runtime in a given process?
>>
>>     Any help and/or ideas are much appreciated. Thanks in advance.
>>
> 
> $r->child_terminate()
> 
> mp2:
> http://perl.apache.org/docs/2.0/api/Apache2/RequestUtil.html#C_child_terminate_ 

	Perfect. Much thanks.

-- 
	Victor Danilchenko
	Senior Software Engineer, AskOnline.net
	victor@askonline.net - 617-273-0119

Re: Help -- how can I make the Apache process die at the end of the request?

Posted by Adam Prime <ad...@utoronto.ca>.
Victor Danilchenko wrote:
>     I need to do it forcibly, no matter what happens during the request. 
> I have to slightly relax security constraints to call an unusual 
> subrequest, and since I cannot guarantee that the cleanup code will be 
> reached (what if the subrequest is terminated by the client, or dies on 
> a bug?), I figure my best bet it to make sure that at the end of the 
> request execution, the current apache process dies so that a new one can 
> be spawned. 'kill $$' is obviously inadequate.
> 
>     Does anyone have any idea how this can be achieved? perhaps 
> utilizing MaxRequestsPerChild somehow, I could trick the parent process 
> into terminating this one after the request completes? or is there some 
> mod_perl feature which tells mod_perl to not re-use the perl runtime in 
> a given process?
> 
>     Any help and/or ideas are much appreciated. Thanks in advance.
> 

$r->child_terminate()

mp2:
http://perl.apache.org/docs/2.0/api/Apache2/RequestUtil.html#C_child_terminate_

mp1:
http://perl.apache.org/docs/1.0/guide/snippets.html#Terminating_a_Child_Process_on_Request_Completion

Adam