<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.iis.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:cs="http://blogs.iis.net/"><channel><title>FastCGI Handler</title><link>http://forums.iis.net/1103.aspx</link><description>Questions related to the FastCGI handler shipping for IIS6</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>handling termination in FastCGI (FCGX_Accept not working as documented)</title><link>http://forums.iis.net/thread/1887264.aspx</link><pubDate>Thu, 11 Dec 2008 09:22:42 GMT</pubDate><guid isPermaLink="false">50bcf3b4-f6fe-4638-adff-0c150e922e99:1887264</guid><dc:creator>Mike Trader</dc:creator><slash:comments>0</slash:comments><comments>http://forums.iis.net/thread/1887264.aspx</comments><wfw:commentRss>http://forums.iis.net/commentrss.aspx?SectionID=1103&amp;PostID=1887264</wfw:commentRss><description>&lt;p&gt;Regardless of whether i set FCGI_FAIL_ACCEPT_ON_INTR or not, I cannot get any return from &lt;/p&gt;&lt;p&gt;FCGX_Accept_r() when my FCGI process is closed by the host (due to timout for example) &lt;/p&gt;&lt;p&gt;searching this forum returns no posts but a google search returns:&lt;/p&gt;&lt;p&gt;http://osdir.com/ml/web.fastcgi.devel/2007-12/msg00002.html&lt;br /&gt;
&amp;gt;&lt;i&gt; I have a signal handler that catches SIGTERM and sets sig_int_flag to 1.&lt;/i&gt;&lt;br /&gt;
&amp;gt;&lt;i&gt; Regardless of whether I use the FCGI_FAIL_ACCEPT_ON_INTR setting or not,&lt;/i&gt;&lt;br /&gt;
&amp;gt;&lt;i&gt; the signal is caught but it never breaks out of the loop and executes&lt;/i&gt;&lt;br /&gt;
&amp;gt;&lt;i&gt; the cleanup code. What I want to do is have the loop exit and run the&lt;/i&gt;&lt;br /&gt;
&amp;gt;&lt;i&gt; cleanup code but I am not sure how to do that with or without the&lt;/i&gt;&lt;br /&gt;
&amp;gt;&lt;i&gt; FCGI_FAIL_ACCEPT_ON_INTR setting.&lt;/i&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;http://www.nabble.com/FCGI_FAIL_ACCEPT_ON_INTR-td7699287.html&lt;/p&gt;&lt;p&gt;&lt;span&gt;&amp;gt; It should work out of the box under Unix, however as
&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;gt; &lt;b class="highlight"&gt;FCGI_FAIL_ACCEPT_ON_INTR&lt;/b&gt; is not supported under windows in the
&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;gt; official devel package a patch is required.&amp;nbsp;
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Is this true?&lt;/p&gt;&lt;pre&gt;What I want to do is have the loop exit and run the&lt;br /&gt;cleanup code...&lt;/pre&gt;&lt;pre&gt;http://mlblog.osdir.com/web.fastcgi.devel/2006-12/index.shtml&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;Am I missing a way to implement this behaviour under IIS? &lt;br /&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;p&gt;http://article.gmane.org/gmane.comp.web.fastcgi.devel/850 &lt;br /&gt;
&lt;/p&gt;&lt;p&gt;Is there a SIG TERM handler in libfcgi.dll?&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;It seems this alos leads to 500 errors&lt;/p&gt;&lt;p&gt;http://www.fastcgi.com/archives/fastcgi-developers/2008-October/000099.html&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;pre&gt;&lt;b&gt;&amp;nbsp;Documentation states:&lt;/b&gt;&lt;/pre&gt;&lt;pre&gt;http://www.fastcgi.com/devkit/doc/FCGI_Accept.3 &lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;

&lt;p&gt;&amp;#39; The FCGI_Accept function accepts a new request from the HTTP server 
&amp;#39; and creates a CGI-compatible execution environment for the request. &lt;/p&gt;

&lt;p&gt;&amp;#39;If the application was invoked as a CGI program, the first call to FCGI_Accept 
&amp;#39;is essentially a no-op and the second call returns -1. 
&amp;#39;This causes a correctly coded FastCGI application to run a single request 
&amp;#39;and exit, giving CGI behavior.
&amp;#39;
&amp;#39;If the application was invoked as a FastCGI server, the first call to FCGI_Accept 
&amp;#39;indicates that the application has completed its initialization and is ready to 
&amp;#39;accept its first request. 
&amp;#39;Subsequent calls to FCGI_Accept indicate that the application has completed 
&amp;#39;processing its current request and is ready to accept a new request.&lt;/p&gt;

&lt;p&gt;&amp;#39;After accepting a new request, FCGI_Accept assigns new values to the 
&amp;#39;global variables: stdin, stdout, stderr, and environ. 
&amp;#39;After FCGI_Accept returns, these variables have the same interpretation 
&amp;#39;as on entry to a CGI program.&lt;/p&gt;

&lt;p&gt;This works as advertised&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;&amp;#39;The FCGI_Accept blocks execution until a client request comes in, and then returns 0. 
&amp;#39;If there is a system failure, or the system administrator terminates 
&amp;#39;the process, Accept will return -1.&lt;/p&gt;

&lt;p&gt;This does not work. 
When the timer triggers, IIS shute the FastCG process down immediately and my cleanup code cannot execute.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>