47277ee
To: vim_dev@googlegroups.com
47277ee
Subject: Patch 7.3.344
47277ee
Fcc: outbox
47277ee
From: Bram Moolenaar <Bram@moolenaar.net>
47277ee
Mime-Version: 1.0
47277ee
Content-Type: text/plain; charset=UTF-8
47277ee
Content-Transfer-Encoding: 8bit
47277ee
------------
47277ee
47277ee
Patch 7.3.344
47277ee
Problem:    Problem with GUI startup related to XInitThreads.
47277ee
Solution:   Use read() and write() instead of fputs() and fread(). (James
47277ee
	    Vega)
47277ee
Files:	    src/gui.c
47277ee
47277ee
47277ee
*** ../vim-7.3.343/src/gui.c	2011-09-14 19:04:35.000000000 +0200
47277ee
--- src/gui.c	2011-10-20 21:23:43.000000000 +0200
47277ee
***************
47277ee
*** 212,218 ****
47277ee
      int		status;
47277ee
      int		exit_status;
47277ee
      pid_t	pid = -1;
47277ee
-     FILE	*parent_file;
47277ee
  
47277ee
      /* Setup a pipe between the child and the parent, so that the parent
47277ee
       * knows when the child has done the setsid() call and is allowed to
47277ee
--- 212,217 ----
47277ee
***************
47277ee
*** 290,308 ****
47277ee
      gui_mch_forked();
47277ee
  # endif
47277ee
  
47277ee
-     if (!pipe_error)
47277ee
- 	parent_file = fdopen(pipefd[1], "w");
47277ee
-     else
47277ee
- 	parent_file = NULL;
47277ee
- 
47277ee
      /* Try to start the GUI */
47277ee
      gui_attempt_start();
47277ee
  
47277ee
      /* Notify the parent */
47277ee
!     if (parent_file != NULL)
47277ee
      {
47277ee
! 	fputs(gui.in_use ? "ok" : "fail", parent_file);
47277ee
! 	fclose(parent_file);
47277ee
      }
47277ee
  
47277ee
      /* If we failed to start the GUI, exit now. */
47277ee
--- 289,305 ----
47277ee
      gui_mch_forked();
47277ee
  # endif
47277ee
  
47277ee
      /* Try to start the GUI */
47277ee
      gui_attempt_start();
47277ee
  
47277ee
      /* Notify the parent */
47277ee
!     if (!pipe_error)
47277ee
      {
47277ee
! 	if (gui.in_use)
47277ee
! 	    write_eintr(pipefd[1], "ok", 3);
47277ee
! 	else
47277ee
! 	    write_eintr(pipefd[1], "fail", 5);
47277ee
! 	close(pipefd[1]);
47277ee
      }
47277ee
  
47277ee
      /* If we failed to start the GUI, exit now. */
47277ee
***************
47277ee
*** 323,339 ****
47277ee
      static int
47277ee
  gui_read_child_pipe(int fd)
47277ee
  {
47277ee
!     size_t	bytes_read;
47277ee
!     FILE	*file;
47277ee
!     char	buffer[10];
47277ee
! 
47277ee
!     file = fdopen(fd, "r");
47277ee
!     if (!file)
47277ee
  	return GUI_CHILD_IO_ERROR;
47277ee
! 
47277ee
!     bytes_read = fread(buffer, sizeof(char), sizeof(buffer)-1, file);
47277ee
!     buffer[bytes_read] = '\0';
47277ee
!     fclose(file);
47277ee
      if (strcmp(buffer, "ok") == 0)
47277ee
  	return GUI_CHILD_OK;
47277ee
      return GUI_CHILD_FAILED;
47277ee
--- 320,335 ----
47277ee
      static int
47277ee
  gui_read_child_pipe(int fd)
47277ee
  {
47277ee
!     long	bytes_read;
47277ee
! #define READ_BUFFER_SIZE 10
47277ee
!     char	buffer[READ_BUFFER_SIZE];
47277ee
! 
47277ee
!     bytes_read = read_eintr(fd, buffer, READ_BUFFER_SIZE - 1);
47277ee
! #undef READ_BUFFER_SIZE
47277ee
!     close(fd);
47277ee
!     if (bytes_read < 0)
47277ee
  	return GUI_CHILD_IO_ERROR;
47277ee
!     buffer[bytes_read] = NUL;
47277ee
      if (strcmp(buffer, "ok") == 0)
47277ee
  	return GUI_CHILD_OK;
47277ee
      return GUI_CHILD_FAILED;
47277ee
*** ../vim-7.3.343/src/version.c	2011-10-20 21:09:25.000000000 +0200
47277ee
--- src/version.c	2011-10-20 21:27:31.000000000 +0200
47277ee
***************
47277ee
*** 716,717 ****
47277ee
--- 716,719 ----
47277ee
  {   /* Add new patch number below this line */
47277ee
+ /**/
47277ee
+     344,
47277ee
  /**/
47277ee
47277ee
-- 
47277ee
From "know your smileys":
47277ee
 *<|:-)	Santa Claus (Ho Ho Ho)
47277ee
47277ee
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
47277ee
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
47277ee
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
47277ee
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///