mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-06-02 02:40:07 +02:00
detect non-blocking fd EOF by read()==0 following poll(), needed on MacOS.
2007-12-06 13:29:00 Tim Janik <timj@imendio.com> * glib/gtester.c (child_report_cb): detect non-blocking fd EOF by read()==0 following poll(), needed on MacOS. svn path=/trunk/; revision=6059
This commit is contained in:
parent
c79ef3793c
commit
8844df9101
@ -1,3 +1,8 @@
|
|||||||
|
2007-12-06 13:29:00 Tim Janik <timj@imendio.com>
|
||||||
|
|
||||||
|
* glib/gtester.c (child_report_cb): detect non-blocking fd EOF
|
||||||
|
by read()==0 following poll(), needed on MacOS.
|
||||||
|
|
||||||
2007-12-06 Mathias Hasselmann <mathias@openismus.com>
|
2007-12-06 Mathias Hasselmann <mathias@openismus.com>
|
||||||
|
|
||||||
* glib/gunidecomp.c: Mention g_utf8_normalize()
|
* glib/gunidecomp.c: Mention g_utf8_normalize()
|
||||||
|
@ -184,12 +184,21 @@ child_report_cb (GIOChannel *source,
|
|||||||
{
|
{
|
||||||
GTestLogBuffer *tlb = data;
|
GTestLogBuffer *tlb = data;
|
||||||
GIOStatus status = G_IO_STATUS_NORMAL;
|
GIOStatus status = G_IO_STATUS_NORMAL;
|
||||||
|
gboolean first_read_eof = FALSE, first_read = TRUE;
|
||||||
gsize length = 0;
|
gsize length = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
guint8 buffer[READ_BUFFER_SIZE];
|
guint8 buffer[READ_BUFFER_SIZE];
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
status = g_io_channel_read_chars (source, (gchar*) buffer, sizeof (buffer), &length, &error);
|
status = g_io_channel_read_chars (source, (gchar*) buffer, sizeof (buffer), &length, &error);
|
||||||
|
if (first_read && (condition & G_IO_IN))
|
||||||
|
{
|
||||||
|
/* on some unixes (MacOS) we need to detect non-blocking fd EOF
|
||||||
|
* by an IO_IN select/poll followed by read()==0.
|
||||||
|
*/
|
||||||
|
first_read_eof = length == 0;
|
||||||
|
}
|
||||||
|
first_read = FALSE;
|
||||||
if (length)
|
if (length)
|
||||||
{
|
{
|
||||||
GTestLogMsg *msg;
|
GTestLogMsg *msg;
|
||||||
@ -206,11 +215,11 @@ child_report_cb (GIOChannel *source,
|
|||||||
while (msg);
|
while (msg);
|
||||||
}
|
}
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
/* ignore the io channel status, which seems to be bogus especially for non blocking fds */
|
/* ignore the io channel status, which will report intermediate EOFs for non blocking fds */
|
||||||
(void) status;
|
(void) status;
|
||||||
}
|
}
|
||||||
while (length > 0);
|
while (length > 0);
|
||||||
if (condition & (G_IO_ERR | G_IO_HUP))
|
if (first_read_eof || (condition & (G_IO_ERR | G_IO_HUP)))
|
||||||
{
|
{
|
||||||
/* if there's no data to read and select() reports an error or hangup,
|
/* if there's no data to read and select() reports an error or hangup,
|
||||||
* the fd must have been closed remotely
|
* the fd must have been closed remotely
|
||||||
|
Loading…
x
Reference in New Issue
Block a user