Karsten Hopp 219fed
To: vim_dev@googlegroups.com
Karsten Hopp 219fed
Subject: Patch 7.3.866
Karsten Hopp 219fed
Fcc: outbox
Karsten Hopp 219fed
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 219fed
Mime-Version: 1.0
Karsten Hopp 219fed
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 219fed
Content-Transfer-Encoding: 8bit
Karsten Hopp 219fed
------------
Karsten Hopp 219fed
Karsten Hopp 219fed
Patch 7.3.866
Karsten Hopp 219fed
Problem:    Not serving the X selection during system() isn't nice.
Karsten Hopp 219fed
Solution:   When using fork() do not loose the selection, keep serving it.
Karsten Hopp 219fed
	    Add a loop similar to handling I/O. (Yukihiro Nakadaira)
Karsten Hopp 219fed
Files:	    src/os_unix.c
Karsten Hopp 219fed
Karsten Hopp 219fed
Karsten Hopp 219fed
*** ../vim-7.3.865/src/os_unix.c	2013-03-13 17:50:20.000000000 +0100
Karsten Hopp 219fed
--- src/os_unix.c	2013-03-19 12:34:04.000000000 +0100
Karsten Hopp 219fed
***************
Karsten Hopp 219fed
*** 132,137 ****
Karsten Hopp 219fed
--- 132,138 ----
Karsten Hopp 219fed
  #  include <X11/Shell.h>
Karsten Hopp 219fed
  #  include <X11/StringDefs.h>
Karsten Hopp 219fed
  static Widget	xterm_Shell = (Widget)0;
Karsten Hopp 219fed
+ static void clip_update __ARGS((void));
Karsten Hopp 219fed
  static void xterm_update __ARGS((void));
Karsten Hopp 219fed
  # endif
Karsten Hopp 219fed
  
Karsten Hopp 219fed
***************
Karsten Hopp 219fed
*** 1138,1148 ****
Karsten Hopp 219fed
--- 1139,1151 ----
Karsten Hopp 219fed
  
Karsten Hopp 219fed
  # if defined(FEAT_CLIPBOARD) && defined(FEAT_X11)
Karsten Hopp 219fed
  static void loose_clipboard __ARGS((void));
Karsten Hopp 219fed
+ # ifdef USE_SYSTEM
Karsten Hopp 219fed
  static void save_clipboard __ARGS((void));
Karsten Hopp 219fed
  static void restore_clipboard __ARGS((void));
Karsten Hopp 219fed
  
Karsten Hopp 219fed
  static void *clip_star_save = NULL;
Karsten Hopp 219fed
  static void *clip_plus_save = NULL;
Karsten Hopp 219fed
+ # endif
Karsten Hopp 219fed
  
Karsten Hopp 219fed
  /*
Karsten Hopp 219fed
   * Called when Vim is going to sleep or execute a shell command.
Karsten Hopp 219fed
***************
Karsten Hopp 219fed
*** 1164,1169 ****
Karsten Hopp 219fed
--- 1167,1173 ----
Karsten Hopp 219fed
      }
Karsten Hopp 219fed
  }
Karsten Hopp 219fed
  
Karsten Hopp 219fed
+ # ifdef USE_SYSTEM
Karsten Hopp 219fed
  /*
Karsten Hopp 219fed
   * Save clipboard text to restore later.
Karsten Hopp 219fed
   */
Karsten Hopp 219fed
***************
Karsten Hopp 219fed
*** 1199,1204 ****
Karsten Hopp 219fed
--- 1203,1209 ----
Karsten Hopp 219fed
  	clip_plus_save = NULL;
Karsten Hopp 219fed
      }
Karsten Hopp 219fed
  }
Karsten Hopp 219fed
+ # endif
Karsten Hopp 219fed
  #endif
Karsten Hopp 219fed
  
Karsten Hopp 219fed
  /*
Karsten Hopp 219fed
***************
Karsten Hopp 219fed
*** 4009,4021 ****
Karsten Hopp 219fed
      if (options & SHELL_COOKED)
Karsten Hopp 219fed
  	settmode(TMODE_COOK);		/* set to normal mode */
Karsten Hopp 219fed
  
Karsten Hopp 219fed
- # if defined(FEAT_CLIPBOARD) && defined(FEAT_X11)
Karsten Hopp 219fed
-     /* Disown the clipboard, because is the executed command tries to obtain a
Karsten Hopp 219fed
-      * selection and we own it we get a deadlock. */
Karsten Hopp 219fed
-     save_clipboard();
Karsten Hopp 219fed
-     loose_clipboard();
Karsten Hopp 219fed
- # endif
Karsten Hopp 219fed
- 
Karsten Hopp 219fed
      /*
Karsten Hopp 219fed
       * Do this loop twice:
Karsten Hopp 219fed
       * 1: find number of arguments
Karsten Hopp 219fed
--- 4014,4019 ----
Karsten Hopp 219fed
***************
Karsten Hopp 219fed
*** 4788,4793 ****
Karsten Hopp 219fed
--- 4786,4796 ----
Karsten Hopp 219fed
  		    }
Karsten Hopp 219fed
  		    else
Karsten Hopp 219fed
  			wait_pid = 0;
Karsten Hopp 219fed
+ 
Karsten Hopp 219fed
+ # if defined(FEAT_CLIPBOARD) && defined(FEAT_X11)
Karsten Hopp 219fed
+ 		    /* Handle any X events, e.g. serving the clipboard. */
Karsten Hopp 219fed
+ 		    clip_update();
Karsten Hopp 219fed
+ # endif
Karsten Hopp 219fed
  		}
Karsten Hopp 219fed
  finished:
Karsten Hopp 219fed
  		p_more = p_more_save;
Karsten Hopp 219fed
***************
Karsten Hopp 219fed
*** 4814,4819 ****
Karsten Hopp 219fed
--- 4817,4861 ----
Karsten Hopp 219fed
  		    close(toshell_fd);
Karsten Hopp 219fed
  		close(fromshell_fd);
Karsten Hopp 219fed
  	    }
Karsten Hopp 219fed
+ # if defined(FEAT_CLIPBOARD) && defined(FEAT_X11)
Karsten Hopp 219fed
+ 	    else
Karsten Hopp 219fed
+ 	    {
Karsten Hopp 219fed
+ 		/*
Karsten Hopp 219fed
+ 		 * Similar to the loop above, but only handle X events, no
Karsten Hopp 219fed
+ 		 * I/O.
Karsten Hopp 219fed
+ 		 */
Karsten Hopp 219fed
+ 		for (;;)
Karsten Hopp 219fed
+ 		{
Karsten Hopp 219fed
+ 		    if (got_int)
Karsten Hopp 219fed
+ 		    {
Karsten Hopp 219fed
+ 			/* CTRL-C sends a signal to the child, we ignore it
Karsten Hopp 219fed
+ 			 * ourselves */
Karsten Hopp 219fed
+ #  ifdef HAVE_SETSID
Karsten Hopp 219fed
+ 			kill(-pid, SIGINT);
Karsten Hopp 219fed
+ #  else
Karsten Hopp 219fed
+ 			kill(0, SIGINT);
Karsten Hopp 219fed
+ #  endif
Karsten Hopp 219fed
+ 			got_int = FALSE;
Karsten Hopp 219fed
+ 		    }
Karsten Hopp 219fed
+ # ifdef __NeXT__
Karsten Hopp 219fed
+ 		    wait_pid = wait4(pid, &status, WNOHANG, (struct rusage *)0);
Karsten Hopp 219fed
+ # else
Karsten Hopp 219fed
+ 		    wait_pid = waitpid(pid, &status, WNOHANG);
Karsten Hopp 219fed
+ # endif
Karsten Hopp 219fed
+ 		    if ((wait_pid == (pid_t)-1 && errno == ECHILD)
Karsten Hopp 219fed
+ 			    || (wait_pid == pid && WIFEXITED(status)))
Karsten Hopp 219fed
+ 		    {
Karsten Hopp 219fed
+ 			wait_pid = pid;
Karsten Hopp 219fed
+ 			break;
Karsten Hopp 219fed
+ 		    }
Karsten Hopp 219fed
+ 
Karsten Hopp 219fed
+ 		    /* Handle any X events, e.g. serving the clipboard. */
Karsten Hopp 219fed
+ 		    clip_update();
Karsten Hopp 219fed
+ 
Karsten Hopp 219fed
+ 		    mch_delay(10L, TRUE);
Karsten Hopp 219fed
+ 		}
Karsten Hopp 219fed
+ 	    }
Karsten Hopp 219fed
+ # endif
Karsten Hopp 219fed
  
Karsten Hopp 219fed
  	    /*
Karsten Hopp 219fed
  	     * Wait until our child has exited.
Karsten Hopp 219fed
***************
Karsten Hopp 219fed
*** 4884,4892 ****
Karsten Hopp 219fed
  # ifdef FEAT_TITLE
Karsten Hopp 219fed
      resettitle();
Karsten Hopp 219fed
  # endif
Karsten Hopp 219fed
- # if defined(FEAT_CLIPBOARD) && defined(FEAT_X11)
Karsten Hopp 219fed
-     restore_clipboard();
Karsten Hopp 219fed
- # endif
Karsten Hopp 219fed
      vim_free(newcmd);
Karsten Hopp 219fed
  
Karsten Hopp 219fed
      return retval;
Karsten Hopp 219fed
--- 4926,4931 ----
Karsten Hopp 219fed
***************
Karsten Hopp 219fed
*** 6868,6873 ****
Karsten Hopp 219fed
--- 6907,6927 ----
Karsten Hopp 219fed
  # endif
Karsten Hopp 219fed
  
Karsten Hopp 219fed
  /*
Karsten Hopp 219fed
+  * Catch up with GUI or X events.
Karsten Hopp 219fed
+  */
Karsten Hopp 219fed
+     static void
Karsten Hopp 219fed
+ clip_update()
Karsten Hopp 219fed
+ {
Karsten Hopp 219fed
+ # ifdef FEAT_GUI
Karsten Hopp 219fed
+     if (gui.in_use)
Karsten Hopp 219fed
+ 	gui_mch_update();
Karsten Hopp 219fed
+     else
Karsten Hopp 219fed
+ # endif
Karsten Hopp 219fed
+     if (xterm_Shell != (Widget)0)
Karsten Hopp 219fed
+ 	xterm_update();
Karsten Hopp 219fed
+ }
Karsten Hopp 219fed
+ 
Karsten Hopp 219fed
+ /*
Karsten Hopp 219fed
   * Catch up with any queued X events.  This may put keyboard input into the
Karsten Hopp 219fed
   * input buffer, call resize call-backs, trigger timers etc.  If there is
Karsten Hopp 219fed
   * nothing in the X event queue (& no timers pending), then we return
Karsten Hopp 219fed
*** ../vim-7.3.865/src/version.c	2013-03-16 21:42:12.000000000 +0100
Karsten Hopp 219fed
--- src/version.c	2013-03-19 12:30:16.000000000 +0100
Karsten Hopp 219fed
***************
Karsten Hopp 219fed
*** 730,731 ****
Karsten Hopp 219fed
--- 730,733 ----
Karsten Hopp 219fed
  {   /* Add new patch number below this line */
Karsten Hopp 219fed
+ /**/
Karsten Hopp 219fed
+     866,
Karsten Hopp 219fed
  /**/
Karsten Hopp 219fed
Karsten Hopp 219fed
-- 
Karsten Hopp 219fed
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 219fed
71. You wonder how people walk
Karsten Hopp 219fed
Karsten Hopp 219fed
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 219fed
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 219fed
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 219fed
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///