Re: running code after FCGX_Accept fails
"Étienne KASPERCZYK" <etienne-bAYckG+VU/[email protected]>
| Newsgroups | gmane.comp.web.fastcgi.devel |
|---|---|
| Message-ID | <[email protected]> |
I guess this is because FCGX_Accept is a blocking function, so the probability that your program was blocked at this very line when killed by apache is high. When Apache shuts it down, it might send a signal, which you could intercept and run the cleanup code before exiting yourself from the code. Regards, Etienne. On 7/27/07, alexander johnson <[email protected]> wrote: > > Hi, > Sorry if I was unclear, given the following code: > > void main() > { > //initialization code > > while(FCGX_Accept( &in, &out, &err, &envp ) >=0) <---- (1) > { > processRequests(); > > } > cleanup(); <----- (2) > > }//end of program > > My code will happily run through the while loop above while my program > is still running. My problem is that when my program stops running > say due to Apache shutting down or closing the fcgi, my code never > gets as far as the cleanup() function (2). When apache terminates the > fcgi, my code exits at (1) so never makes it to (2). I need to run > (2) before the program exits. No matter what way the fcgi is > terminated it will always exit at (1) > > > Thanks > > Alex > > On 7/27/07, Sven Verdoolaege <[email protected]> wrote: > > On Thu, Jul 26, 2007 at 04:51:02PM +0100, alexander johnson wrote: > > > Hi, > > > There some very important cleanup code i need to run after FCGX_Accept > > > == -1 and exits its loop. The problem is that the program exits > > > immediately after FCGX_Accept == -1 so cant run any code after. > > > > You'll have to be a bit more specific. Are you saying that FCGX_Accept > > never returns and just exists or that your code exits after FCGX_Accept > > returns? In the latter case, there's not much we can do to help you. > > > > In any case, FCGX_Accept does not return -1, unless the error happens > > to be EPERM. Why do you think it does? > > > > skimo > > > > > -- > Alex > ___________________________________ > fastcgi-developers mailing list > http://fastcgi.com/fastcgi-developers/ > ___________________________________ fastcgi-developers mailing list http://fastcgi.com/fastcgi-developers/