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