4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: When using cscope temporary files are left behind.
12 Solution: Send the quit command to cscope and give it two seconds to exit
13 nicely before killing it. (partly by Dominique Pelle)
14 Files: src/if_cscope.c
17 *** ../vim-7.1.278/src/if_cscope.c Fri Sep 14 19:56:18 2007
18 --- src/if_cscope.c Sat Mar 15 12:38:12 2008
22 return CSCOPE_SUCCESS;
25 + #if defined(UNIX) && defined(SIGALRM)
27 + * Used to catch and ignore SIGALRM below.
31 + sig_handler SIGDEFARG(sigarg)
39 * PRIVATE: cs_release_csp
49 * Trying to exit normally (not sure whether it is fit to UNIX cscope
55 (void)fputs("q\n", csinfo[i].to_fp);
56 (void)fflush(csinfo[i].to_fp);
63 + # if defined(HAVE_SIGACTION)
64 + struct sigaction sa, old;
66 + /* Use sigaction() to limit the waiting time to two seconds. */
67 + sa.sa_handler = sig_handler;
68 + sa.sa_flags = SA_NODEFER;
69 + sigaction(SIGALRM, &sa, &old);
70 + alarm(2); /* 2 sec timeout */
72 + /* Block until cscope exits or until timer expires */
73 + pid = waitpid(csinfo[i].pid, &pstat, 0);
75 + /* cancel pending alarm if still there and restore signal */
77 + sigaction(SIGALRM, &old, NULL);
81 + /* Can't use sigaction(), loop for two seconds. First yield the CPU
82 + * to give cscope a chance to exit quickly. */
84 + for (waited = 0; waited < 40; ++waited)
86 + pid = waitpid(csinfo[i].pid, &pstat, WNOHANG);
88 + break; /* break unless the process is still running */
89 + mch_delay(50, FALSE); /* sleep 50 ms */
93 + * If the cscope process is still running: kill it.
94 + * Safety check: If the PID would be zero here, the entire X session
95 + * would be killed. -1 and 1 are dangerous as well.
97 + if (pid < 0 && csinfo[i].pid > 1)
99 + kill(csinfo[i].pid, SIGTERM);
100 + (void)waitpid(csinfo[i].pid, &pstat, 0);
104 if (csinfo[i].hProc != NULL)
106 /* Give cscope a chance to exit normally */
109 if (csinfo[i].to_fp != NULL)
110 (void)fclose(csinfo[i].to_fp);
113 - * Safety check: If the PID would be zero here, the entire X session would
114 - * be killed. -1 and 1 are dangerous as well.
117 - if (csinfo[i].pid > 1)
119 - kill(csinfo[i].pid, SIGTERM);
120 - (void)waitpid(csinfo[i].pid, &pstat, 0);
126 vim_free(csinfo[i].fname);
128 *** ../vim-7.1.278/src/version.c Wed Mar 12 21:47:31 2008
129 --- src/version.c Sat Mar 15 12:38:58 2008
133 { /* Add new patch number below this line */
139 hundred-and-one symptoms of being an internet addict:
140 130. You can't get out of your desk even if it's time to eat or time
141 to go to the bathroom.
143 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
144 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
145 \\\ download, build and distribute -- http://www.A-A-P.org ///
146 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///