To: vim-dev@vim.org Subject: Patch 6.0.242 Fcc: outbox From: Bram Moolenaar MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.0.242 Problem: GUI: On a system with an Exceed X server sometimes get a "Bad Window" error. (Tommi Maekitalo) Solution: When forking, use a pipe to wait in the parent for the child to have done the setsid() call. Files: src/gui.c *** ../vim60.241/src/gui.c Mon Feb 11 15:45:47 2002 --- src/gui.c Thu Feb 21 12:11:52 2002 *************** *** 107,119 **** */ if (gui.in_use && dofork) { 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(100L, TRUE); /* * The parent must skip the normal exit() processing, the child --- 107,136 ---- */ if (gui.in_use && dofork) { + int pipefd[2]; /* pipe between parent and child */ + int pipe_error; + char dummy; + + /* Setup a pipe between the child and the parent, so that the parent + * knows when the child has done the setsid() call and is allowed to + * exit. */ + pipe_error = (pipe(pipefd) < 0); 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). */ ! if (pipe_error) ! ui_delay(300L, TRUE); ! else ! { ! /* The read returns when the child closes the pipe (or when ! * the child dies for some reason). */ ! close(pipefd[1]); ! (void)read(pipefd[0], &dummy, (size_t)1); ! close(pipefd[0]); ! } /* * The parent must skip the normal exit() processing, the child *************** *** 134,139 **** --- 151,161 ---- (void)setpgid(0, 0); # endif # endif + if (!pipe_error) + { + close(pipefd[0]); + close(pipefd[1]); + } } #else # if defined(__QNXNTO__) *** ../vim60.241/src/version.c Wed Feb 20 22:07:15 2002 --- src/version.c Thu Feb 21 12:29:54 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 242, /**/ -- I once paid $12 to peer at the box that held King Tutankhamen's little bandage-covered midget corpse at the De Young Museum in San Francisco. I remember thinking how pleased he'd be about the way things turned out in his afterlife. (Scott Adams - The Dilbert principle) /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ /// Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim \\\ \\\ Project leader for A-A-P -- http://www.a-a-p.org /// \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///