To: vim-dev@vim.org Subject: patch 5.4.17 Fcc: outbox From: Bram Moolenaar ------------ Patch 5.4.17 Problem: GUI: When started from inside gvim with ":!gvim", Vim would not start. ":!gvim -f" works fine. Solution: After forking, wait a moment in the parent process, to give the child a chance to set its process group. Files: src/gui.c *** ../vim-5.4/src/gui.c Sun Aug 8 21:29:08 1999 --- src/gui.c Sun Aug 8 21:18:09 1999 *************** *** 101,106 **** --- 101,114 ---- if (pid == 0) /* child */ { (void)close(pfd[0]); /* child closes its read end */ + + /* Do the setsid() first, otherwise the exit() of the parent may + * kill the child too (when starting gvim from inside a gvim). */ + # if defined(HAVE_SETSID) + (void)setsid(); + # else + (void)setpgid(0, 0); + # endif termcapinit((char_u *)"builtin_gui"); /* goes to gui_init() */ gui.starting = recursive - 1; (void)write(pfd[1], &gui.in_use, sizeof(int)); *************** *** 108,118 **** if (!gui.in_use) exit(1); - # if defined(HAVE_SETSID) - (void)setsid(); - # else - (void)setpgid(0, 0); - # endif #ifdef AUTOCMD apply_autocmds(EVENT_GUIENTER, NULL, NULL, FALSE, curbuf); #endif --- 116,121 ---- *************** *** 167,173 **** --- 170,183 ---- { pid = fork(); if (pid > 0) /* Parent */ + { + /* Give the child some time to do the setsid(), otherwise the + * exit() may kill the child too (when starting gvim from inside a + * gvim). */ + ui_delay(100, TRUE); exit(0); + } + # if defined(HAVE_SETSID) || defined(HAVE_SETPGID) /* * Change our process group. On some systems/shells a CTRL-C in the *** ../vim-5.4/src/version.h Sun Aug 8 14:46:41 1999 --- src/version.h Sun Aug 8 21:30:06 1999 *************** *** 19,26 **** #define VIM_VERSION_MINOR_STR "4" #define VIM_VERSION_BUILD 57 #define VIM_VERSION_BUILD_STR "57" ! #define VIM_VERSION_PATCHLEVEL 16 ! #define VIM_VERSION_PATCHLEVEL_STR "16" /* * VIM_VERSION_NODOT is used for the runtime directory name. --- 19,26 ---- #define VIM_VERSION_MINOR_STR "4" #define VIM_VERSION_BUILD 57 #define VIM_VERSION_BUILD_STR "57" ! #define VIM_VERSION_PATCHLEVEL 17 ! #define VIM_VERSION_PATCHLEVEL_STR "17" /* * VIM_VERSION_NODOT is used for the runtime directory name. *************** *** 30,35 **** */ #define VIM_VERSION_NODOT "vim54" #define VIM_VERSION_SHORT "5.4" ! #define VIM_VERSION_MEDIUM "5.4.16" ! #define VIM_VERSION_LONG "VIM - Vi IMproved 5.4.16 (1999 Aug 8)" ! #define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 5.4.16 (1999 Aug 8, compiled " --- 30,35 ---- */ #define VIM_VERSION_NODOT "vim54" #define VIM_VERSION_SHORT "5.4" ! #define VIM_VERSION_MEDIUM "5.4.17" ! #define VIM_VERSION_LONG "VIM - Vi IMproved 5.4.17 (1999 Aug 8)" ! #define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 5.4.17 (1999 Aug 8, compiled " -- BLACK KNIGHT: The Black Knight always triumphs. Have at you! ARTHUR takes his last leg off. The BLACK KNIGHT's body lands upright. BLACK KNIGHT: All right, we'll call it a draw. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD --/-/---- Bram Moolenaar ---- Bram@moolenaar.net ---- Bram@vim.org ---\-\-- \ \ www.vim.org/iccf www.moolenaar.net www.vim.org / /