]> git.pld-linux.org Git - packages/vim.git/blob - 7.3.296
- add patches 7.3.619-743
[packages/vim.git] / 7.3.296
1 To: vim_dev@googlegroups.com
2 Subject: Patch 7.3.296
3 Fcc: outbox
4 From: Bram Moolenaar <Bram@moolenaar.net>
5 Mime-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8 ------------
9
10 Patch 7.3.296
11 Problem:    When writing to an external command a zombie process may be left
12             behind.
13 Solution:   Wait on the process. (James Vega)
14 Files:      src/os_unix.c
15
16
17 *** ../vim-7.3.295/src/os_unix.c        2011-09-07 14:06:38.000000000 +0200
18 --- src/os_unix.c       2011-09-07 14:54:11.000000000 +0200
19 ***************
20 *** 154,159 ****
21 --- 154,166 ----
22   
23   static void may_core_dump __ARGS((void));
24   
25 + #ifdef HAVE_UNION_WAIT
26 + typedef union wait waitstatus;
27 + #else
28 + typedef int waitstatus;
29 + #endif
30 + static int  wait4pid __ARGS((pid_t, waitstatus *));
31
32   static int  WaitForChar __ARGS((long));
33   #if defined(__BEOS__)
34   int  RealWaitForChar __ARGS((int, long, int *));
35 ***************
36 *** 3660,3665 ****
37 --- 3667,3713 ----
38       /* Nothing to do. */
39   }
40   
41 + /*
42 +  * Wait for process "child" to end.
43 +  * Return "child" if it exited properly, <= 0 on error.
44 +  */
45 +     static pid_t
46 + wait4pid(child, status)
47 +     pid_t     child;
48 +     waitstatus        *status;
49 + {
50 +     pid_t wait_pid = 0;
51
52 +     while (wait_pid != child)
53 +     {
54 + # ifdef _THREAD_SAFE
55 +       /* Ugly hack: when compiled with Python threads are probably
56 +        * used, in which case wait() sometimes hangs for no obvious
57 +        * reason.  Use waitpid() instead and loop (like the GUI). */
58 + #  ifdef __NeXT__
59 +       wait_pid = wait4(child, status, WNOHANG, (struct rusage *)0);
60 + #  else
61 +       wait_pid = waitpid(child, status, WNOHANG);
62 + #  endif
63 +       if (wait_pid == 0)
64 +       {
65 +           /* Wait for 1/100 sec before trying again. */
66 +           mch_delay(10L, TRUE);
67 +           continue;
68 +       }
69 + # else
70 +       wait_pid = wait(status);
71 + # endif
72 +       if (wait_pid <= 0
73 + # ifdef ECHILD
74 +               && errno == ECHILD
75 + # endif
76 +          )
77 +           break;
78 +     }
79 +     return wait_pid;
80 + }
81
82       int
83   mch_call_shell(cmd, options)
84       char_u    *cmd;
85 ***************
86 *** 4234,4240 ****
87                     {
88                         MSG_PUTS(_("\nCannot fork\n"));
89                     }
90 !                   else if (wpid == 0)
91                     {
92                         linenr_T    lnum = curbuf->b_op_start.lnum;
93                         int         written = 0;
94 --- 4282,4288 ----
95                     {
96                         MSG_PUTS(_("\nCannot fork\n"));
97                     }
98 !                   else if (wpid == 0) /* child */
99                     {
100                         linenr_T    lnum = curbuf->b_op_start.lnum;
101                         int         written = 0;
102 ***************
103 *** 4242,4248 ****
104                         char_u      *s;
105                         size_t      l;
106   
107 -                       /* child */
108                         close(fromshell_fd);
109                         for (;;)
110                         {
111 --- 4290,4295 ----
112 ***************
113 *** 4287,4293 ****
114                         }
115                         _exit(0);
116                     }
117 !                   else
118                     {
119                         close(toshell_fd);
120                         toshell_fd = -1;
121 --- 4334,4340 ----
122                         }
123                         _exit(0);
124                     }
125 !                   else /* parent */
126                     {
127                         close(toshell_fd);
128                         toshell_fd = -1;
129 ***************
130 *** 4584,4590 ****
131                      * typed characters (otherwise we would lose typeahead).
132                      */
133   # ifdef __NeXT__
134 !                   wait_pid = wait4(pid, &status, WNOHANG, (struct rusage *) 0);
135   # else
136                     wait_pid = waitpid(pid, &status, WNOHANG);
137   # endif
138 --- 4631,4637 ----
139                      * typed characters (otherwise we would lose typeahead).
140                      */
141   # ifdef __NeXT__
142 !                   wait_pid = wait4(pid, &status, WNOHANG, (struct rusage *)0);
143   # else
144                     wait_pid = waitpid(pid, &status, WNOHANG);
145   # endif
146 ***************
147 *** 4633,4665 ****
148              * Don't wait if wait_pid was already set above, indicating the
149              * child already exited.
150              */
151 !           while (wait_pid != pid)
152 !           {
153 ! # ifdef _THREAD_SAFE
154 !               /* Ugly hack: when compiled with Python threads are probably
155 !                * used, in which case wait() sometimes hangs for no obvious
156 !                * reason.  Use waitpid() instead and loop (like the GUI). */
157 ! #  ifdef __NeXT__
158 !               wait_pid = wait4(pid, &status, WNOHANG, (struct rusage *)0);
159 ! #  else
160 !               wait_pid = waitpid(pid, &status, WNOHANG);
161 ! #  endif
162 !               if (wait_pid == 0)
163 !               {
164 !                   /* Wait for 1/100 sec before trying again. */
165 !                   mch_delay(10L, TRUE);
166 !                   continue;
167 !               }
168 ! # else
169 !               wait_pid = wait(&status);
170 ! # endif
171 !               if (wait_pid <= 0
172 ! # ifdef ECHILD
173 !                       && errno == ECHILD
174 ! # endif
175 !                  )
176 !                   break;
177 !           }
178   
179   # ifdef FEAT_GUI
180             /* Close slave side of pty.  Only do this after the child has
181 --- 4680,4687 ----
182              * Don't wait if wait_pid was already set above, indicating the
183              * child already exited.
184              */
185 !           if (wait_pid != pid)
186 !               wait_pid = wait4pid(pid, &status);
187   
188   # ifdef FEAT_GUI
189             /* Close slave side of pty.  Only do this after the child has
190 ***************
191 *** 4672,4678 ****
192 --- 4694,4703 ----
193             /* Make sure the child that writes to the external program is
194              * dead. */
195             if (wpid > 0)
196 +           {
197                 kill(wpid, SIGKILL);
198 +               wait4pid(wpid, NULL);
199 +           }
200   
201             /*
202              * Set to raw mode right now, otherwise a CTRL-C after
203 *** ../vim-7.3.295/src/version.c        2011-09-07 14:06:39.000000000 +0200
204 --- src/version.c       2011-09-07 15:03:24.000000000 +0200
205 ***************
206 *** 711,712 ****
207 --- 711,714 ----
208   {   /* Add new patch number below this line */
209 + /**/
210 +     296,
211   /**/
212
213 -- 
214 If your company is not involved in something called "ISO 9000" you probably
215 have no idea what it is.  If your company _is_ involved in ISO 9000 then you
216 definitely have no idea what it is.
217                                 (Scott Adams - The Dilbert principle)
218
219  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
220 ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
221 \\\  an exciting new programming language -- http://www.Zimbu.org        ///
222  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
This page took 0.061455 seconds and 3 git commands to generate.