summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2011-02-18 16:47:03 +0100
committerDenys Vlasenko <dvlasenk@redhat.com>2011-02-18 16:47:03 +0100
commit1bbaeb7a85c57ccedd6987d9c0e6157e2aba3563 (patch)
tree95cecbd7faba35f4ac8014b452e2cf9537ee65d8
parent0f37f38fc2f1963d42de7ca8e11c3f10c5e69f17 (diff)
downloadabrt-1bbaeb7a85c57ccedd6987d9c0e6157e2aba3563.tar.gz
abrt-1bbaeb7a85c57ccedd6987d9c0e6157e2aba3563.tar.xz
abrt-1bbaeb7a85c57ccedd6987d9c0e6157e2aba3563.zip
gui-wizard-gtk: ensure we don't block on reading analyze output
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
-rw-r--r--src/gui-wizard-gtk/wizard.c2
-rw-r--r--src/lib/xfuncs.c10
2 files changed, 10 insertions, 2 deletions
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
index 690c9ecf..4bdc230e 100644
--- a/src/gui-wizard-gtk/wizard.c
+++ b/src/gui-wizard-gtk/wizard.c
@@ -271,6 +271,7 @@ static gboolean consume_cmd_output(GIOChannel *source, GIOCondition condition, g
*/
xmove_fd(evd->run_state->command_out_fd, evd->fd);
evd->run_state->command_out_fd = evd->fd; /* just to keep it consistent */
+ ndelay_on(evd->fd);
return TRUE; /* "please don't remove this event (yet)" */
}
@@ -304,6 +305,7 @@ static void next_page(GtkAssistant *assistant, gpointer user_data)
struct analyze_event_data *evd = xzalloc(sizeof(*evd));
evd->run_state = state;
evd->fd = state->command_out_fd;
+ ndelay_on(evd->fd);
evd->channel = g_io_channel_unix_new(evd->fd);
/*evd->event_source_id = */ g_io_add_watch(evd->channel,
G_IO_IN | G_IO_ERR | G_IO_HUP, /* need HUP to detect EOF w/o any data */
diff --git a/src/lib/xfuncs.c b/src/lib/xfuncs.c
index be02c56a..f451693a 100644
--- a/src/lib/xfuncs.c
+++ b/src/lib/xfuncs.c
@@ -26,12 +26,18 @@
/* Turn on nonblocking I/O on a fd */
int ndelay_on(int fd)
{
- return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
+ int flags = fcntl(fd, F_GETFL);
+ if (flags & O_NONBLOCK)
+ return 0;
+ return fcntl(fd, F_SETFL, flags | O_NONBLOCK);
}
int ndelay_off(int fd)
{
- return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_NONBLOCK);
+ int flags = fcntl(fd, F_GETFL);
+ if (!(flags & O_NONBLOCK))
+ return 0;
+ return fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
}
int close_on_exec_on(int fd)