From: Owen Taylor Date: Mon, 2 Jun 2003 18:20:25 +0000 (+0000) Subject: Patch from Jeffrey Stedfast (#104825) X-Git-Tag: GLIB_2_3_0~181 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5f5ab2384c4b5de5be30125ad44fa600e4f6ad5c;p=platform%2Fupstream%2Fglib.git Patch from Jeffrey Stedfast (#104825) Mon Jun 2 14:18:21 2003 Owen Taylor Patch from Jeffrey Stedfast (#104825) * glib/gspawn.c (read_data): Don't read() into '&buf', while this is technically okay - it is clearer as just 'buf'. (write_all): New helper function that handles write() interrupts. (write_err_and_exit): Use write_all() instead of write(). (fork_exec_with_pipes): Same here. --- diff --git a/ChangeLog b/ChangeLog index ab2226d..565fb8f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Mon Jun 2 14:18:21 2003 Owen Taylor + + Patch from Jeffrey Stedfast (#104825) + + * glib/gspawn.c (read_data): Don't read() into '&buf', while this + is technically okay - it is clearer as just 'buf'. + (write_all): New helper function that handles write() interrupts. + (write_err_and_exit): Use write_all() instead of write(). + (fork_exec_with_pipes): Same here. + Sun Jun 1 09:42:36 2003 Owen Taylor * glib/giochannel.c (g_io_error_get_from_g_error): Put diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index ab2226d..565fb8f 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,13 @@ +Mon Jun 2 14:18:21 2003 Owen Taylor + + Patch from Jeffrey Stedfast (#104825) + + * glib/gspawn.c (read_data): Don't read() into '&buf', while this + is technically okay - it is clearer as just 'buf'. + (write_all): New helper function that handles write() interrupts. + (write_err_and_exit): Use write_all() instead of write(). + (fork_exec_with_pipes): Same here. + Sun Jun 1 09:42:36 2003 Owen Taylor * glib/giochannel.c (g_io_error_get_from_g_error): Put diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index ab2226d..565fb8f 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,13 @@ +Mon Jun 2 14:18:21 2003 Owen Taylor + + Patch from Jeffrey Stedfast (#104825) + + * glib/gspawn.c (read_data): Don't read() into '&buf', while this + is technically okay - it is clearer as just 'buf'. + (write_all): New helper function that handles write() interrupts. + (write_err_and_exit): Use write_all() instead of write(). + (fork_exec_with_pipes): Same here. + Sun Jun 1 09:42:36 2003 Owen Taylor * glib/giochannel.c (g_io_error_get_from_g_error): Put diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index ab2226d..565fb8f 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,13 @@ +Mon Jun 2 14:18:21 2003 Owen Taylor + + Patch from Jeffrey Stedfast (#104825) + + * glib/gspawn.c (read_data): Don't read() into '&buf', while this + is technically okay - it is clearer as just 'buf'. + (write_all): New helper function that handles write() interrupts. + (write_err_and_exit): Use write_all() instead of write(). + (fork_exec_with_pipes): Same here. + Sun Jun 1 09:42:36 2003 Owen Taylor * glib/giochannel.c (g_io_error_get_from_g_error): Put diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index ab2226d..565fb8f 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,13 @@ +Mon Jun 2 14:18:21 2003 Owen Taylor + + Patch from Jeffrey Stedfast (#104825) + + * glib/gspawn.c (read_data): Don't read() into '&buf', while this + is technically okay - it is clearer as just 'buf'. + (write_all): New helper function that handles write() interrupts. + (write_err_and_exit): Use write_all() instead of write(). + (fork_exec_with_pipes): Same here. + Sun Jun 1 09:42:36 2003 Owen Taylor * glib/giochannel.c (g_io_error_get_from_g_error): Put diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index ab2226d..565fb8f 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,13 @@ +Mon Jun 2 14:18:21 2003 Owen Taylor + + Patch from Jeffrey Stedfast (#104825) + + * glib/gspawn.c (read_data): Don't read() into '&buf', while this + is technically okay - it is clearer as just 'buf'. + (write_all): New helper function that handles write() interrupts. + (write_err_and_exit): Use write_all() instead of write(). + (fork_exec_with_pipes): Same here. + Sun Jun 1 09:42:36 2003 Owen Taylor * glib/giochannel.c (g_io_error_get_from_g_error): Put diff --git a/glib/gspawn.c b/glib/gspawn.c index 2af786d..77d44fb 100644 --- a/glib/gspawn.c +++ b/glib/gspawn.c @@ -148,7 +148,7 @@ read_data (GString *str, again: - bytes = read (fd, &buf, 4096); + bytes = read (fd, buf, 4096); if (bytes == 0) return READ_EOF; @@ -793,13 +793,36 @@ exec_err_to_g_error (gint en) } } +static gssize +write_all (gint fd, gconstpointer vbuf, gsize to_write) +{ + gchar *buf = (gchar *) vbuf; + + while (to_write > 0) + { + gssize count = write (fd, buf, to_write); + if (count < 0) + { + if (errno != EINTR) + return FALSE; + } + else + { + to_write -= count; + buf += count; + } + } + + return TRUE; +} + static void write_err_and_exit (gint fd, gint msg) { gint en = errno; - write (fd, &msg, sizeof(msg)); - write (fd, &en, sizeof(en)); + write_all (fd, &msg, sizeof(msg)); + write_all (fd, &en, sizeof(en)); _exit (1); } @@ -1081,8 +1104,8 @@ fork_exec_with_pipes (gboolean intermediate_child, if (grandchild_pid < 0) { /* report -1 as child PID */ - write (child_pid_report_pipe[1], &grandchild_pid, - sizeof(grandchild_pid)); + write_all (child_pid_report_pipe[1], &grandchild_pid, + sizeof(grandchild_pid)); write_err_and_exit (child_err_report_pipe[1], CHILD_FORK_FAILED); @@ -1107,7 +1130,7 @@ fork_exec_with_pipes (gboolean intermediate_child, } else { - write (child_pid_report_pipe[1], &grandchild_pid, sizeof(grandchild_pid)); + write_all (child_pid_report_pipe[1], &grandchild_pid, sizeof(grandchild_pid)); close_and_invalidate (&child_pid_report_pipe[1]); _exit (0);