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