<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: using select on a fifo</title>
	<atom:link href="http://www.outflux.net/blog/archives/2008/03/09/using-select-on-a-fifo/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.outflux.net/blog/archives/2008/03/09/using-select-on-a-fifo/</link>
	<description>code is freedom -- patching my itch</description>
	<lastBuildDate>Tue, 24 Jan 2012 19:58:01 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
	<item>
		<title>By: TOMi</title>
		<link>http://www.outflux.net/blog/archives/2008/03/09/using-select-on-a-fifo/comment-page-1/#comment-1027</link>
		<dc:creator>TOMi</dc:creator>
		<pubDate>Mon, 20 Sep 2010 21:21:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.outflux.net/blog/archives/2008/03/09/using-select-on-a-fifo/#comment-1027</guid>
		<description>Again, this look like the answer I needed - thanks!</description>
		<content:encoded><![CDATA[<p>Again, this look like the answer I needed &#8211; thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cfchris6</title>
		<link>http://www.outflux.net/blog/archives/2008/03/09/using-select-on-a-fifo/comment-page-1/#comment-663</link>
		<dc:creator>cfchris6</dc:creator>
		<pubDate>Wed, 15 Oct 2008 10:38:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.outflux.net/blog/archives/2008/03/09/using-select-on-a-fifo/#comment-663</guid>
		<description>Thanks for the hint, this helped me out of misery :)</description>
		<content:encoded><![CDATA[<p>Thanks for the hint, this helped me out of misery :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Schnouki</title>
		<link>http://www.outflux.net/blog/archives/2008/03/09/using-select-on-a-fifo/comment-page-1/#comment-656</link>
		<dc:creator>Schnouki</dc:creator>
		<pubDate>Sun, 14 Sep 2008 15:57:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.outflux.net/blog/archives/2008/03/09/using-select-on-a-fifo/#comment-656</guid>
		<description>Thanks for the tip, it&#039;s just what I was looking for!</description>
		<content:encoded><![CDATA[<p>Thanks for the tip, it&#8217;s just what I was looking for!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aron Rubin</title>
		<link>http://www.outflux.net/blog/archives/2008/03/09/using-select-on-a-fifo/comment-page-1/#comment-607</link>
		<dc:creator>Aron Rubin</dc:creator>
		<pubDate>Wed, 12 Mar 2008 01:11:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.outflux.net/blog/archives/2008/03/09/using-select-on-a-fifo/#comment-607</guid>
		<description>You would need to use clearerr. Actually that is a major problem with GIOChannel is that there is no way to clear the EOF (that I can find). Standard IO has clearerr which clears both errors and EOF status. This is an idle reading function from one of my programs (sanitized a little):

&lt;pre&gt;
static gboolean parser_read_icb( SimExec *sim ) {
  SimExec *sim;
  char buf[64] = &quot;&quot;, *str;
  gsize bytes_read = 0, curpos, endpos;
  ScenarioStream *ss = NULL;
  
  g_return_val_if_fail( IS_SIM_EXEC(sim), FALSE );
  
  ss = sim-&gt;priv-&gt;parser;
  
  g_return_val_if_fail( sim-&gt;priv-&gt;output_fp, FALSE );
  
  clearerr( sim-&gt;priv-&gt;output_fp );
  if( sim-&gt;priv-&gt;status == SIM_EXEC_RUNNING ) {
    curpos = ftell( sim-&gt;priv-&gt;output_fp );
    fseek( sim-&gt;priv-&gt;output_fp, 0, SEEK_END );
    endpos = ftell( sim-&gt;priv-&gt;output_fp );
    fseek( sim-&gt;priv-&gt;output_fp, curpos, SEEK_SET );
    if( endpos - curpos priv-&gt;output_fp );
  bytes_read = fread( buf, 1, sizeof(buf), sim-&gt;priv-&gt;output_fp );
  if( bytes_read priv-&gt;output_fp ) &#124;&#124;
			  ferror( sim-&gt;priv-&gt;output_fp )) ) {
    if( sim-&gt;priv-&gt;status != SIM_EXEC_RUNNING ) {
      fclose( sim-&gt;priv-&gt;output_fp );
      sim-&gt;priv-&gt;output_fp = NULL;
      return( FALSE );
    }
  } else if( bytes_read &gt; 0 ) {
    for( str = buf; *str; str++ )
      if( *str == &#039;\\n&#039; ) 
	ss-&gt;lineno++;
    ss-&gt;pspool =
      sxml_parse( ss-&gt;pspool, &amp;ss-&gt;pslen, buf, bytes_read,
                  (SXMLStartTagFunc)stream_start,
                  (SXMLEndTagFunc)stream_end,
                  (SXMLCharsFunc)scenario_chars, ss );
  }
  return( TRUE );
}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>You would need to use clearerr. Actually that is a major problem with GIOChannel is that there is no way to clear the EOF (that I can find). Standard IO has clearerr which clears both errors and EOF status. This is an idle reading function from one of my programs (sanitized a little):</p>
<p>static gboolean parser_read_icb( SimExec *sim ) {<br />
  SimExec *sim;<br />
  char buf[64] = &#8220;&#8221;, *str;<br />
  gsize bytes_read = 0, curpos, endpos;<br />
  ScenarioStream *ss = NULL;</p>
<p>  g_return_val_if_fail( IS_SIM_EXEC(sim), FALSE );</p>
<p>  ss = sim-&gt;priv-&gt;parser;</p>
<p>  g_return_val_if_fail( sim-&gt;priv-&gt;output_fp, FALSE );</p>
<p>  clearerr( sim-&gt;priv-&gt;output_fp );<br />
  if( sim-&gt;priv-&gt;status == SIM_EXEC_RUNNING ) {<br />
    curpos = ftell( sim-&gt;priv-&gt;output_fp );<br />
    fseek( sim-&gt;priv-&gt;output_fp, 0, SEEK_END );<br />
    endpos = ftell( sim-&gt;priv-&gt;output_fp );<br />
    fseek( sim-&gt;priv-&gt;output_fp, curpos, SEEK_SET );<br />
    if( endpos &#8211; curpos priv-&gt;output_fp );<br />
  bytes_read = fread( buf, 1, sizeof(buf), sim-&gt;priv-&gt;output_fp );<br />
  if( bytes_read priv-&gt;output_fp ) ||<br />
			  ferror( sim-&gt;priv-&gt;output_fp )) ) {<br />
    if( sim-&gt;priv-&gt;status != SIM_EXEC_RUNNING ) {<br />
      fclose( sim-&gt;priv-&gt;output_fp );<br />
      sim-&gt;priv-&gt;output_fp = NULL;<br />
      return( FALSE );<br />
    }<br />
  } else if( bytes_read &gt; 0 ) {<br />
    for( str = buf; *str; str++ )<br />
      if( *str == &#8216;\\n&#8217; )<br />
	ss-&gt;lineno++;<br />
    ss-&gt;pspool =<br />
      sxml_parse( ss-&gt;pspool, &amp;ss-&gt;pslen, buf, bytes_read,<br />
                  (SXMLStartTagFunc)stream_start,<br />
                  (SXMLEndTagFunc)stream_end,<br />
                  (SXMLCharsFunc)scenario_chars, ss );<br />
  }<br />
  return( TRUE );<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Schroeder</title>
		<link>http://www.outflux.net/blog/archives/2008/03/09/using-select-on-a-fifo/comment-page-1/#comment-606</link>
		<dc:creator>Jeff Schroeder</dc:creator>
		<pubDate>Mon, 10 Mar 2008 13:36:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.outflux.net/blog/archives/2008/03/09/using-select-on-a-fifo/#comment-606</guid>
		<description>Very informative post Kees, keep it up.</description>
		<content:encoded><![CDATA[<p>Very informative post Kees, keep it up.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

