<?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"
	>
<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>
	<pubDate>Thu, 21 Aug 2008 17:50:06 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Aron Rubin</title>
		<link>http://www.outflux.net/blog/archives/2008/03/09/using-select-on-a-fifo/#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] = "", *str;
  gsize bytes_read = 0, curpos, endpos;
  ScenarioStream *ss = NULL;
  
  g_return_val_if_fail( IS_SIM_EXEC(sim), FALSE );
  
  ss = sim-&#62;priv-&#62;parser;
  
  g_return_val_if_fail( sim-&#62;priv-&#62;output_fp, FALSE );
  
  clearerr( sim-&#62;priv-&#62;output_fp );
  if( sim-&#62;priv-&#62;status == SIM_EXEC_RUNNING ) {
    curpos = ftell( sim-&#62;priv-&#62;output_fp );
    fseek( sim-&#62;priv-&#62;output_fp, 0, SEEK_END );
    endpos = ftell( sim-&#62;priv-&#62;output_fp );
    fseek( sim-&#62;priv-&#62;output_fp, curpos, SEEK_SET );
    if( endpos - curpos priv-&#62;output_fp );
  bytes_read = fread( buf, 1, sizeof(buf), sim-&#62;priv-&#62;output_fp );
  if( bytes_read priv-&#62;output_fp ) &#124;&#124;
			  ferror( sim-&#62;priv-&#62;output_fp )) ) {
    if( sim-&#62;priv-&#62;status != SIM_EXEC_RUNNING ) {
      fclose( sim-&#62;priv-&#62;output_fp );
      sim-&#62;priv-&#62;output_fp = NULL;
      return( FALSE );
    }
  } else if( bytes_read &#62; 0 ) {
    for( str = buf; *str; str++ )
      if( *str == '\\n' ) 
	ss-&#62;lineno++;
    ss-&#62;pspool =
      sxml_parse( ss-&#62;pspool, &#38;ss-&#62;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>
<pre>
static gboolean parser_read_icb( SimExec *sim ) {
  SimExec *sim;
  char buf[64] = &#8220;&#8221;, *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 ) ||
			  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 == &#8216;\\n&#8217; )
	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 );
}
</pre>
]]></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-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>
