Branch: refs/heads/master Author: Dimitar Zhekov dimitar.zhekov@gmail.com Committer: Dimitar Zhekov dimitar.zhekov@gmail.com Date: Sat, 18 Apr 2015 08:47:31 UTC Commit: 902681d260435fde5181652839a9e49170150c41 https://github.com/geany/geany/commit/902681d260435fde5181652839a9e49170150c...
Log Message: ----------- Fix for the broken I/O watch conditions on child exit under OSX
Under OSX, after child death, the read watches receive input conditions instead of error conditions, so we convert the termination statuses (ERROR and EOF) into their respective conditions. Should not hurt the other OS.
Modified Paths: -------------- src/spawn.c
Modified: src/spawn.c 19 lines changed, 14 insertions(+), 5 deletions(-) =================================================================== @@ -665,13 +665,14 @@ static gboolean spawn_read_cb(GIOChannel *channel, GIOCondition condition, gpoin if (condition & (G_IO_IN | G_IO_PRI)) { gsize chars_read; + GIOStatus status;
if (line_buffer) { gsize n = line_buffer->len;
- while ((g_io_channel_read_chars(channel, line_buffer->str + n, - DEFAULT_IO_LENGTH, &chars_read, NULL) == G_IO_STATUS_NORMAL)) + while ((status = g_io_channel_read_chars(channel, line_buffer->str + n, + DEFAULT_IO_LENGTH, &chars_read, NULL)) == G_IO_STATUS_NORMAL) { g_string_set_size(line_buffer, n + chars_read);
@@ -706,8 +707,8 @@ static gboolean spawn_read_cb(GIOChannel *channel, GIOCondition condition, gpoin } else { - while (g_io_channel_read_chars(channel, buffer->str, sc->max_length, - &chars_read, NULL) == G_IO_STATUS_NORMAL) + while ((status = g_io_channel_read_chars(channel, buffer->str, sc->max_length, + &chars_read, NULL)) == G_IO_STATUS_NORMAL) { g_string_set_size(buffer, chars_read); /* data only, failures are reported separately below */ @@ -717,6 +718,14 @@ static gboolean spawn_read_cb(GIOChannel *channel, GIOCondition condition, gpoin break; } } + + /* Under OSX, after child death, the read watches receive input conditions instead + of error conditions, so we convert the termination statuses into conditions. + Should not hurt the other OS. */ + if (status == G_IO_STATUS_ERROR) + failure |= G_IO_ERR; + else if (status == G_IO_STATUS_EOF) + failure |= G_IO_HUP; }
if (failure) /* we must signal the callback */ @@ -734,7 +743,7 @@ static gboolean spawn_read_cb(GIOChannel *channel, GIOCondition condition, gpoin g_string_truncate(buffer, 0); }
- sc->cb.read(buffer, condition, sc->cb_data); + sc->cb.read(buffer, condition | failure, sc->cb_data); }
if (buffer != sc->buffer)
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).