Patch from Jeffrey Stedfast <fejj@ximian.com> (#104825)
authorOwen Taylor <otaylor@redhat.com>
Mon, 2 Jun 2003 18:20:25 +0000 (18:20 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Mon, 2 Jun 2003 18:20:25 +0000 (18:20 +0000)
Mon Jun  2 14:18:21 2003  Owen Taylor  <otaylor@redhat.com>

        Patch from Jeffrey Stedfast <fejj@ximian.com> (#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.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
glib/gspawn.c

index ab2226d..565fb8f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Mon Jun  2 14:18:21 2003  Owen Taylor  <otaylor@redhat.com>
+
+       Patch from Jeffrey Stedfast <fejj@ximian.com> (#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  <otaylor@redhat.com>
 
        * glib/giochannel.c (g_io_error_get_from_g_error): Put 
index ab2226d..565fb8f 100644 (file)
@@ -1,3 +1,13 @@
+Mon Jun  2 14:18:21 2003  Owen Taylor  <otaylor@redhat.com>
+
+       Patch from Jeffrey Stedfast <fejj@ximian.com> (#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  <otaylor@redhat.com>
 
        * glib/giochannel.c (g_io_error_get_from_g_error): Put 
index ab2226d..565fb8f 100644 (file)
@@ -1,3 +1,13 @@
+Mon Jun  2 14:18:21 2003  Owen Taylor  <otaylor@redhat.com>
+
+       Patch from Jeffrey Stedfast <fejj@ximian.com> (#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  <otaylor@redhat.com>
 
        * glib/giochannel.c (g_io_error_get_from_g_error): Put 
index ab2226d..565fb8f 100644 (file)
@@ -1,3 +1,13 @@
+Mon Jun  2 14:18:21 2003  Owen Taylor  <otaylor@redhat.com>
+
+       Patch from Jeffrey Stedfast <fejj@ximian.com> (#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  <otaylor@redhat.com>
 
        * glib/giochannel.c (g_io_error_get_from_g_error): Put 
index ab2226d..565fb8f 100644 (file)
@@ -1,3 +1,13 @@
+Mon Jun  2 14:18:21 2003  Owen Taylor  <otaylor@redhat.com>
+
+       Patch from Jeffrey Stedfast <fejj@ximian.com> (#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  <otaylor@redhat.com>
 
        * glib/giochannel.c (g_io_error_get_from_g_error): Put 
index ab2226d..565fb8f 100644 (file)
@@ -1,3 +1,13 @@
+Mon Jun  2 14:18:21 2003  Owen Taylor  <otaylor@redhat.com>
+
+       Patch from Jeffrey Stedfast <fejj@ximian.com> (#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  <otaylor@redhat.com>
 
        * glib/giochannel.c (g_io_error_get_from_g_error): Put 
index 2af786d..77d44fb 100644 (file)
@@ -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);