]> git.pld-linux.org Git - packages/vim.git/blob - 7.2.300
- new
[packages/vim.git] / 7.2.300
1 To: vim-dev@vim.org
2 Subject: Patch 7.2.300
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.2.300
11 Problem:    Vim doesn't close file descriptors when forking and executing
12             another command, e.g., ":shell".
13 Solution:   Use FD_CLOEXEC when available. (James Vega)
14 Files:      src/auto/configure, src/config.h.in, src/configure.in,
15             src/ex_cmdds2.c, src/fileio.c, src/memfile.c, src/memline.c
16
17
18 *** ../vim-7.2.299/src/auto/configure   2009-11-17 12:08:48.000000000 +0100
19 --- src/auto/configure  2009-11-17 13:09:03.000000000 +0100
20 ***************
21 *** 15174,15179 ****
22 --- 15174,15231 ----
23   $as_echo "yes" >&6; }
24   fi
25   
26 + { $as_echo "$as_me:$LINENO: checking for FD_CLOEXEC" >&5
27 + $as_echo_n "checking for FD_CLOEXEC... " >&6; }
28 + cat >conftest.$ac_ext <<_ACEOF
29 + /* confdefs.h.  */
30 + _ACEOF
31 + cat confdefs.h >>conftest.$ac_ext
32 + cat >>conftest.$ac_ext <<_ACEOF
33 + /* end confdefs.h.  */
34 + #if HAVE_FCNTL_H
35 + # include <fcntl.h>
36 + #endif
37 + int
38 + main ()
39 + {
40 +       int flag = FD_CLOEXEC;
41 +   ;
42 +   return 0;
43 + }
44 + _ACEOF
45 + rm -f conftest.$ac_objext
46 + if { (ac_try="$ac_compile"
47 + case "(($ac_try" in
48 +   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
49 +   *) ac_try_echo=$ac_try;;
50 + esac
51 + eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
52 + $as_echo "$ac_try_echo") >&5
53 +   (eval "$ac_compile") 2>conftest.er1
54 +   ac_status=$?
55 +   grep -v '^ *+' conftest.er1 >conftest.err
56 +   rm -f conftest.er1
57 +   cat conftest.err >&5
58 +   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
59 +   (exit $ac_status); } && {
60 +        test -z "$ac_c_werror_flag" ||
61 +        test ! -s conftest.err
62 +        } && test -s conftest.$ac_objext; then
63 +   { $as_echo "$as_me:$LINENO: result: yes" >&5
64 + $as_echo "yes" >&6; }; cat >>confdefs.h <<\_ACEOF
65 + #define HAVE_FD_CLOEXEC 1
66 + _ACEOF
67
68 + else
69 +   $as_echo "$as_me: failed program was:" >&5
70 + sed 's/^/| /' conftest.$ac_ext >&5
71
72 +       { $as_echo "$as_me:$LINENO: result: not usable" >&5
73 + $as_echo "not usable" >&6; }
74 + fi
75
76 + rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
77
78   { $as_echo "$as_me:$LINENO: checking for rename" >&5
79   $as_echo_n "checking for rename... " >&6; }
80   cat >conftest.$ac_ext <<_ACEOF
81 *** ../vim-7.2.299/src/config.h.in      2009-11-17 12:08:48.000000000 +0100
82 --- src/config.h.in     2009-11-17 13:01:36.000000000 +0100
83 ***************
84 *** 388,390 ****
85 --- 388,393 ----
86   
87   /* Define if you want XSMP interaction as well as vanilla swapfile safety */
88   #undef USE_XSMP_INTERACT
89
90 + /* Define if fcntl()'s F_SETFD command knows about FD_CLOEXEC */
91 + #undef HAVE_FD_CLOEXEC
92 *** ../vim-7.2.299/src/configure.in     2009-11-17 12:08:48.000000000 +0100
93 --- src/configure.in    2009-11-17 13:01:36.000000000 +0100
94 ***************
95 *** 2855,2860 ****
96 --- 2855,2870 ----
97     AC_MSG_RESULT(yes)
98   fi
99   
100 + dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
101 + AC_MSG_CHECKING(for FD_CLOEXEC)
102 + AC_TRY_COMPILE(
103 + [#if HAVE_FCNTL_H
104 + # include <fcntl.h>
105 + #endif],
106 + [     int flag = FD_CLOEXEC;],
107 +       AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
108 +       AC_MSG_RESULT(not usable))
109
110   dnl rename needs to be checked separately to work on Nextstep with cc
111   AC_MSG_CHECKING(for rename)
112   AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
113 *** ../vim-7.2.299/src/fileio.c 2009-11-17 14:57:19.000000000 +0100
114 --- src/fileio.c        2009-11-17 13:22:06.000000000 +0100
115 ***************
116 *** 2254,2259 ****
117 --- 2254,2267 ----
118   
119       if (!read_buffer && !read_stdin)
120         close(fd);                              /* errors are ignored */
121 + #ifdef HAVE_FD_CLOEXEC
122 +     else
123 +     {
124 +       int fdflags = fcntl(fd, F_GETFD);
125 +       if (fdflags >= 0 && (fdflags & FD_CLOEXEC) == 0)
126 +           fcntl(fd, F_SETFD, fdflags | FD_CLOEXEC);
127 +     }
128 + #endif
129       vim_free(buffer);
130   
131   #ifdef HAVE_DUP
132 *** ../vim-7.2.299/src/memfile.c        2008-07-13 19:39:39.000000000 +0200
133 --- src/memfile.c       2009-11-17 13:22:15.000000000 +0100
134 ***************
135 *** 1343,1348 ****
136 --- 1343,1353 ----
137       }
138       else
139       {
140 + #ifdef HAVE_FD_CLOEXEC
141 +       int fdflags = fcntl(mfp->mf_fd, F_GETFD);
142 +       if (fdflags >= 0 && (fdflags & FD_CLOEXEC) == 0)
143 +           fcntl(mfp->mf_fd, F_SETFD, fdflags | FD_CLOEXEC);
144 + #endif
145   #ifdef HAVE_SELINUX
146         mch_copy_sec(fname, mfp->mf_fname);
147   #endif
148 *** ../vim-7.2.299/src/memline.c        2009-11-03 15:32:58.000000000 +0100
149 --- src/memline.c       2009-11-17 13:21:40.000000000 +0100
150 ***************
151 *** 382,388 ****
152       dp->db_index[0] = --dp->db_txt_start;     /* at end of block */
153       dp->db_free -= 1 + INDEX_SIZE;
154       dp->db_line_count = 1;
155 !     *((char_u *)dp + dp->db_txt_start) = NUL; /* emtpy line */
156   
157       return OK;
158   
159 --- 382,388 ----
160       dp->db_index[0] = --dp->db_txt_start;     /* at end of block */
161       dp->db_free -= 1 + INDEX_SIZE;
162       dp->db_line_count = 1;
163 !     *((char_u *)dp + dp->db_txt_start) = NUL; /* empty line */
164   
165       return OK;
166   
167 ***************
168 *** 490,495 ****
169 --- 490,502 ----
170             EMSG(_("E301: Oops, lost the swap file!!!"));
171             return;
172         }
173 + #ifdef HAVE_FD_CLOEXEC
174 +       {
175 +           int fdflags = fcntl(mfp->mf_fd, F_GETFD);
176 +           if (fdflags >= 0 && (fdflags & FD_CLOEXEC) == 0)
177 +               fcntl(mfp->mf_fd, F_SETFD, fdflags | FD_CLOEXEC);
178 +       }
179 + #endif
180       }
181       if (!success)
182         EMSG(_("E302: Could not rename swap file"));
183 *** ../vim-7.2.299/src/version.c        2009-11-17 16:08:12.000000000 +0100
184 --- src/version.c       2009-11-17 17:09:43.000000000 +0100
185 ***************
186 *** 683,684 ****
187 --- 683,686 ----
188   {   /* Add new patch number below this line */
189 + /**/
190 +     300,
191   /**/
192
193 -- 
194             |
195
196 Ceci n'est pas une pipe.
197
198  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
199 ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
200 \\\        download, build and distribute -- http://www.A-A-P.org        ///
201  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
This page took 0.058179 seconds and 3 git commands to generate.