| To: vim-dev@vim.org |
| Subject: Patch 7.1.288 |
| Fcc: outbox |
| From: Bram Moolenaar <Bram@moolenaar.net> |
| Mime-Version: 1.0 |
| Content-Type: text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding: 8bit |
| |
| |
| Patch 7.1.288 (after 7.1.281) |
| Problem: Cscope still leaves behind temp files when using gvim. |
| Solution: When getting the ECHILD error loop for a while until cscope exits. |
| (Dominique Pelle) |
| Files: if_cscope.c |
| |
| |
| |
| |
| |
| *** 2130,2135 **** |
| --- 2130,2136 ---- |
| } |
| #if defined(UNIX) |
| { |
| + int waitpid_errno; |
| int pstat; |
| pid_t pid; |
| |
| |
| *** 2145,2150 **** |
| --- 2146,2152 ---- |
| |
| /* Block until cscope exits or until timer expires */ |
| pid = waitpid(csinfo[i].pid, &pstat, 0); |
| + waitpid_errno = errno; |
| |
| /* cancel pending alarm if still there and restore signal */ |
| alarm(0); |
| |
| *** 2158,2163 **** |
| --- 2160,2166 ---- |
| for (waited = 0; waited < 40; ++waited) |
| { |
| pid = waitpid(csinfo[i].pid, &pstat, WNOHANG); |
| + waitpid_errno = errno; |
| if (pid != 0) |
| break; /* break unless the process is still running */ |
| mch_delay(50, FALSE); /* sleep 50 ms */ |
| |
| *** 2170,2177 **** |
| */ |
| if (pid < 0 && csinfo[i].pid > 1) |
| { |
| ! kill(csinfo[i].pid, SIGKILL); |
| ! (void)waitpid(csinfo[i].pid, &pstat, 0); |
| } |
| } |
| #else /* !UNIX */ |
| --- 2173,2212 ---- |
| */ |
| if (pid < 0 && csinfo[i].pid > 1) |
| { |
| ! # ifdef ECHILD |
| ! int alive = TRUE; |
| ! |
| ! if (waitpid_errno == ECHILD) |
| ! { |
| ! /* |
| ! * When using 'vim -g', vim is forked and cscope process is |
| ! * no longer a child process but a sibling. So waitpid() |
| ! * fails with errno being ECHILD (No child processes). |
| ! * Don't send SIGKILL to cscope immediately but wait |
| ! * (polling) for it to exit normally as result of sending |
| ! * the "q" command, hence giving it a chance to clean up |
| ! * its temporary files. |
| ! */ |
| ! int waited; |
| ! |
| ! sleep(0); |
| ! for (waited = 0; waited < 40; ++waited) |
| ! { |
| ! /* Check whether cscope process is still alive */ |
| ! if (kill(csinfo[i].pid, 0) != 0) |
| ! { |
| ! alive = FALSE; /* cscope process no longer exists */ |
| ! break; |
| ! } |
| ! mch_delay(50, FALSE); /* sleep 50ms */ |
| ! } |
| ! } |
| ! if (alive) |
| ! # endif |
| ! { |
| ! kill(csinfo[i].pid, SIGKILL); |
| ! (void)waitpid(csinfo[i].pid, &pstat, 0); |
| ! } |
| } |
| } |
| #else /* !UNIX */ |
| |
| |
| |
| *** 668,669 **** |
| --- 668,671 ---- |
| { /* Add new patch number below this line */ |
| + /**/ |
| + 288, |
| /**/ |
| |
| -- |
| hundred-and-one symptoms of being an internet addict: |
| 204. You're being audited because you mailed your tax return to the IRC. |
| |
| /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ |
| /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ |
| \\\ download, build and distribute -- http://www.A-A-P.org /// |
| \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |