home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 6.0.242 < prev    next >
Encoding:
Internet Message Format  |  2002-02-20  |  2.9 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.0.242
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=ISO-8859-1
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 6.0.242
  11. Problem:    GUI: On a system with an Exceed X server sometimes get a "Bad
  12.         Window" error. (Tommi Maekitalo)
  13. Solution:   When forking, use a pipe to wait in the parent for the child to
  14.         have done the setsid() call.
  15. Files:        src/gui.c
  16.  
  17.  
  18. *** ../vim60.241/src/gui.c    Mon Feb 11 15:45:47 2002
  19. --- src/gui.c    Thu Feb 21 12:11:52 2002
  20. ***************
  21. *** 107,119 ****
  22.        */
  23.       if (gui.in_use && dofork)
  24.       {
  25.       pid = fork();
  26.       if (pid > 0)        /* Parent */
  27.       {
  28.           /* Give the child some time to do the setsid(), otherwise the
  29.            * exit() may kill the child too (when starting gvim from inside a
  30.            * gvim). */
  31. !         ui_delay(100L, TRUE);
  32.   
  33.           /*
  34.            * The parent must skip the normal exit() processing, the child
  35. --- 107,136 ----
  36.        */
  37.       if (gui.in_use && dofork)
  38.       {
  39. +     int    pipefd[2];    /* pipe between parent and child */
  40. +     int    pipe_error;
  41. +     char    dummy;
  42. +     /* Setup a pipe between the child and the parent, so that the parent
  43. +      * knows when the child has done the setsid() call and is allowed to
  44. +      * exit. */
  45. +     pipe_error = (pipe(pipefd) < 0);
  46.       pid = fork();
  47.       if (pid > 0)        /* Parent */
  48.       {
  49.           /* Give the child some time to do the setsid(), otherwise the
  50.            * exit() may kill the child too (when starting gvim from inside a
  51.            * gvim). */
  52. !         if (pipe_error)
  53. !         ui_delay(300L, TRUE);
  54. !         else
  55. !         {
  56. !         /* The read returns when the child closes the pipe (or when
  57. !          * the child dies for some reason). */
  58. !         close(pipefd[1]);
  59. !         (void)read(pipefd[0], &dummy, (size_t)1);
  60. !         close(pipefd[0]);
  61. !         }
  62.   
  63.           /*
  64.            * The parent must skip the normal exit() processing, the child
  65. ***************
  66. *** 134,139 ****
  67. --- 151,161 ----
  68.           (void)setpgid(0, 0);
  69.   #  endif
  70.   # endif
  71. +     if (!pipe_error)
  72. +     {
  73. +         close(pipefd[0]);
  74. +         close(pipefd[1]);
  75. +     }
  76.       }
  77.   #else
  78.   # if defined(__QNXNTO__)
  79. *** ../vim60.241/src/version.c    Wed Feb 20 22:07:15 2002
  80. --- src/version.c    Thu Feb 21 12:29:54 2002
  81. ***************
  82. *** 608,609 ****
  83. --- 608,611 ----
  84.   {   /* Add new patch number below this line */
  85. + /**/
  86. +     242,
  87.   /**/
  88.  
  89. -- 
  90. I once paid $12 to peer at the box that held King Tutankhamen's little
  91. bandage-covered midget corpse at the De Young Museum in San Francisco.  I
  92. remember thinking how pleased he'd be about the way things turned out in his
  93. afterlife.
  94.                 (Scott Adams - The Dilbert principle)
  95.  
  96.  ///  Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net  \\\
  97. ///   Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim   \\\
  98. \\\           Project leader for A-A-P -- http://www.a-a-p.org           ///
  99.  \\\  Help me helping AIDS orphans in Uganda - http://iccf-holland.org  ///
  100.