Skip to content
Snippets Groups Projects
Commit 5e01dbe7 authored by tag2y19's avatar tag2y19 Committed by Tom Greig
Browse files

Handle EOF on stdin properly

parent 4ecda605
No related branches found
No related tags found
No related merge requests found
...@@ -216,16 +216,26 @@ static int listener_check( GSource* source ) { ...@@ -216,16 +216,26 @@ static int listener_check( GSource* source ) {
struct fd_source* fd_source = (struct fd_source*) source; struct fd_source* fd_source = (struct fd_source*) source;
return g_source_query_unix_fd( source, fd_source->tag ) & G_IO_IN; unsigned int res = g_source_query_unix_fd( source, fd_source->tag );
return 0 != res;
} }
static int listener_dispatch( static int listener_dispatch(
GSource* source, GSourceFunc funk, void* data ) { GSource* source, GSourceFunc funk, void* data ) {
(void) source; struct fd_source* fd_source = (struct fd_source*) source;
if ( g_source_query_unix_fd(
source, fd_source->tag ) & G_IO_IN ) {
return ( *funk )( data ); return ( *funk )( data );
} else if ( g_source_query_unix_fd(
source, fd_source->tag ) & ( G_IO_HUP | G_IO_ERR ) ) {
return G_SOURCE_REMOVE;
} else {
return G_SOURCE_CONTINUE;
}
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment