Re: Meaning of G_IO_STATUS_AGAIN apart from resource temporarily unavailable ?
- From: Chris Vine <chris cvine freeserve co uk>
- To: gtk-app-devel-list gnome org
- Cc:
- Subject: Re: Meaning of G_IO_STATUS_AGAIN apart from resource temporarily unavailable ?
- Date: Tue, 25 Oct 2005 22:48:49 +0100
On Tuesday 25 October 2005 20:38, Colossus wrote:
...
ioc_cpio = g_io_channel_new_file ( tmp , "r" , NULL );
g_io_channel_set_encoding (ioc_cpio , NULL , NULL);
g_io_channel_set_flags ( ioc_cpio , G_IO_FLAG_NONBLOCK , NULL );
while ( g_io_channel_read_chars ( ioc_cpio , buffer,
sizeof(buffer)-1, &bytes_read, &error ) == G_IO_STATUS_NORMAL )
{
if ( error != NULL )
{
g_print ("Read Error: %s\n" , error->message);
g_error_free ( error );
g_io_channel_shutdown ( ioc_cpio , TRUE , NULL );
g_io_channel_unref ( ioc_cpio );
g_spawn_close_pid ( child_pid );
g_free (tmp);
}
g_print ("Bytes letti: %d\t" , bytes_read);
status = g_io_channel_write_chars ( input_ioc , buffer ,
bytes_read , &bytes_write , &error );
g_io_channel_flush ( input_ioc , NULL );
g_print ("Bytes scritti: %d\n" , bytes_write);
if (bytes_write == 0 ) g_print ("Status: %d\n" , status );
if ( status == G_IO_STATUS_ERROR )
{
g_print ("Write Error: %s\n" , error->message);
g_error_free ( error );
g_io_channel_shutdown ( ioc_cpio,TRUE,NULL );
g_io_channel_unref ( ioc_cpio );
g_spawn_close_pid ( child_pid );
g_free (tmp);
}
}
g_io_channel_shutdown ( ioc_cpio , TRUE , NULL );
g_io_channel_unref ( ioc_cpio );
//tmp contains the pointer to the CPIO filename in /tmp
//unlink (tmp);
g_free (tmp);
Why there are no example on giochannels ? The docs are not enough for
common mortals like me and others.
You have set the flags on the read GIOChannel object as non-blocking. Why did
you do that - it seems pointless in the snippet of code you have provided?
I do not use GIOChannels but I imagine G_IO_STATUS_AGAIN indicates a
non-blocking read has returned without reading a character but end-of-file
has not been reached. If you have a non-blocking read then you must expect
to handle this condition. This is pretty elementary stuff which any
competent programmer would know about, so your complaints about the
documentation are off the mark.
Chris
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]