]> git.pld-linux.org Git - packages/vim.git/blob - 7.1.279
- updated to 7.1.326
[packages/vim.git] / 7.1.279
1 To: vim-dev@vim.org
2 Subject: Patch 7.1.279
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 7.1.279
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
15
16
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
19 ***************
20 *** 2096,2101 ****
21 --- 2096,2113 ----
22       return CSCOPE_SUCCESS;
23   }
24   
25 + #if defined(UNIX) && defined(SIGALRM)
26 + /*
27 +  * Used to catch and ignore SIGALRM below.
28 +  */
29 + /* ARGSUSED */
30 +     static RETSIGTYPE
31 + sig_handler SIGDEFARG(sigarg)
32 + {
33 +     /* do nothing */
34 +     SIGRETURN;
35 + }
36 + #endif
37   
38   /*
39    * PRIVATE: cs_release_csp
40 ***************
41 *** 2108,2116 ****
42       int i;
43       int freefnpp;
44   {
45 - #if defined(UNIX)
46 -     int pstat;
47 - #else
48       /*
49        * Trying to exit normally (not sure whether it is fit to UNIX cscope
50        */
51 --- 2120,2125 ----
52 ***************
53 *** 2119,2124 ****
54 --- 2128,2179 ----
55         (void)fputs("q\n", csinfo[i].to_fp);
56         (void)fflush(csinfo[i].to_fp);
57       }
58 + #if defined(UNIX)
59 +     {
60 +       int pstat;
61 +       pid_t pid;
62
63 + # if defined(HAVE_SIGACTION)
64 +       struct sigaction sa, old;
65
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 */
71
72 +       /* Block until cscope exits or until timer expires */
73 +       pid = waitpid(csinfo[i].pid, &pstat, 0);
74
75 +       /* cancel pending alarm if still there and restore signal */
76 +       alarm(0);
77 +       sigaction(SIGALRM, &old, NULL);
78 + # else
79 +       int waited;
80
81 +       /* Can't use sigaction(), loop for two seconds.  First yield the CPU
82 +        * to give cscope a chance to exit quickly. */
83 +       sleep(0);
84 +       for (waited = 0; waited < 40; ++waited)
85 +       {
86 +           pid = waitpid(csinfo[i].pid, &pstat, WNOHANG);
87 +           if (pid != 0)
88 +               break;  /* break unless the process is still running */
89 +           mch_delay(50, FALSE); /* sleep 50 ms */
90 +       }
91 + # endif
92 +       /*
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.
96 +        */
97 +       if (pid < 0 && csinfo[i].pid > 1)
98 +       {
99 +           kill(csinfo[i].pid, SIGTERM);
100 +           (void)waitpid(csinfo[i].pid, &pstat, 0);
101 +       }
102 +     }
103 + #else  /* !UNIX */
104       if (csinfo[i].hProc != NULL)
105       {
106         /* Give cscope a chance to exit normally */
107 ***************
108 *** 2133,2150 ****
109       if (csinfo[i].to_fp != NULL)
110         (void)fclose(csinfo[i].to_fp);
111   
112 -     /*
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.
115 -      */
116 - #if defined(UNIX)
117 -     if (csinfo[i].pid > 1)
118 -     {
119 -       kill(csinfo[i].pid, SIGTERM);
120 -       (void)waitpid(csinfo[i].pid, &pstat, 0);
121 -     }
122 - #endif
123
124       if (freefnpp)
125       {
126         vim_free(csinfo[i].fname);
127 --- 2188,2193 ----
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
130 ***************
131 *** 668,669 ****
132 --- 668,671 ----
133   {   /* Add new patch number below this line */
134 + /**/
135 +     279,
136   /**/
137
138 -- 
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.
142
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    ///
This page took 0.075953 seconds and 3 git commands to generate.