1 To: vim_dev@googlegroups.com
4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: When writing to an external command a zombie process may be left
13 Solution: Wait on the process. (James Vega)
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
23 static void may_core_dump __ARGS((void));
25 + #ifdef HAVE_UNION_WAIT
26 + typedef union wait waitstatus;
28 + typedef int waitstatus;
30 + static int wait4pid __ARGS((pid_t, waitstatus *));
32 static int WaitForChar __ARGS((long));
34 int RealWaitForChar __ARGS((int, long, int *));
42 + * Wait for process "child" to end.
43 + * Return "child" if it exited properly, <= 0 on error.
46 + wait4pid(child, status)
52 + while (wait_pid != child)
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). */
59 + wait_pid = wait4(child, status, WNOHANG, (struct rusage *)0);
61 + wait_pid = waitpid(child, status, WNOHANG);
65 + /* Wait for 1/100 sec before trying again. */
66 + mch_delay(10L, TRUE);
70 + wait_pid = wait(status);
83 mch_call_shell(cmd, options)
88 MSG_PUTS(_("\nCannot fork\n"));
92 linenr_T lnum = curbuf->b_op_start.lnum;
96 MSG_PUTS(_("\nCannot fork\n"));
98 ! else if (wpid == 0) /* child */
100 linenr_T lnum = curbuf->b_op_start.lnum;
131 * typed characters (otherwise we would lose typeahead).
134 ! wait_pid = wait4(pid, &status, WNOHANG, (struct rusage *) 0);
136 wait_pid = waitpid(pid, &status, WNOHANG);
139 * typed characters (otherwise we would lose typeahead).
142 ! wait_pid = wait4(pid, &status, WNOHANG, (struct rusage *)0);
144 wait_pid = waitpid(pid, &status, WNOHANG);
148 * Don't wait if wait_pid was already set above, indicating the
149 * child already exited.
151 ! while (wait_pid != pid)
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). */
158 ! wait_pid = wait4(pid, &status, WNOHANG, (struct rusage *)0);
160 ! wait_pid = waitpid(pid, &status, WNOHANG);
164 ! /* Wait for 1/100 sec before trying again. */
165 ! mch_delay(10L, TRUE);
169 ! wait_pid = wait(&status);
180 /* Close slave side of pty. Only do this after the child has
182 * Don't wait if wait_pid was already set above, indicating the
183 * child already exited.
185 ! if (wait_pid != pid)
186 ! wait_pid = wait4pid(pid, &status);
189 /* Close slave side of pty. Only do this after the child has
193 /* Make sure the child that writes to the external program is
198 + wait4pid(wpid, NULL);
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
208 { /* Add new patch number below this line */
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)
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 ///