summaryrefslogtreecommitdiffstats
path: root/gvim/vim-7.2/7.2.300
blob: f88035e677db258ec5599e8db1b1d4f5845c9268 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
To: vim-dev@vim.org
Subject: Patch 7.2.300
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.2.300
Problem:    Vim doesn't close file descriptors when forking and executing
	    another command, e.g., ":shell".
Solution:   Use FD_CLOEXEC when available. (James Vega)
Files:	    src/auto/configure, src/config.h.in, src/configure.in,
	    src/ex_cmdds2.c, src/fileio.c, src/memfile.c, src/memline.c


*** ../vim-7.2.299/src/auto/configure	2009-11-17 12:08:48.000000000 +0100
--- src/auto/configure	2009-11-17 13:09:03.000000000 +0100
***************
*** 15174,15179 ****
--- 15174,15231 ----
  $as_echo "yes" >&6; }
  fi
  
+ { $as_echo "$as_me:$LINENO: checking for FD_CLOEXEC" >&5
+ $as_echo_n "checking for FD_CLOEXEC... " >&6; }
+ cat >conftest.$ac_ext <<_ACEOF
+ /* confdefs.h.  */
+ _ACEOF
+ cat confdefs.h >>conftest.$ac_ext
+ cat >>conftest.$ac_ext <<_ACEOF
+ /* end confdefs.h.  */
+ #if HAVE_FCNTL_H
+ # include <fcntl.h>
+ #endif
+ int
+ main ()
+ {
+ 	int flag = FD_CLOEXEC;
+   ;
+   return 0;
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+ if { (ac_try="$ac_compile"
+ case "(($ac_try" in
+   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+   *) ac_try_echo=$ac_try;;
+ esac
+ eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+ $as_echo "$ac_try_echo") >&5
+   (eval "$ac_compile") 2>conftest.er1
+   ac_status=$?
+   grep -v '^ *+' conftest.er1 >conftest.err
+   rm -f conftest.er1
+   cat conftest.err >&5
+   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   (exit $ac_status); } && {
+ 	 test -z "$ac_c_werror_flag" ||
+ 	 test ! -s conftest.err
+        } && test -s conftest.$ac_objext; then
+   { $as_echo "$as_me:$LINENO: result: yes" >&5
+ $as_echo "yes" >&6; }; cat >>confdefs.h <<\_ACEOF
+ #define HAVE_FD_CLOEXEC 1
+ _ACEOF
+ 
+ else
+   $as_echo "$as_me: failed program was:" >&5
+ sed 's/^/| /' conftest.$ac_ext >&5
+ 
+ 	{ $as_echo "$as_me:$LINENO: result: not usable" >&5
+ $as_echo "not usable" >&6; }
+ fi
+ 
+ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ 
  { $as_echo "$as_me:$LINENO: checking for rename" >&5
  $as_echo_n "checking for rename... " >&6; }
  cat >conftest.$ac_ext <<_ACEOF
*** ../vim-7.2.299/src/config.h.in	2009-11-17 12:08:48.000000000 +0100
--- src/config.h.in	2009-11-17 13:01:36.000000000 +0100
***************
*** 388,390 ****
--- 388,393 ----
  
  /* Define if you want XSMP interaction as well as vanilla swapfile safety */
  #undef USE_XSMP_INTERACT
+ 
+ /* Define if fcntl()'s F_SETFD command knows about FD_CLOEXEC */
+ #undef HAVE_FD_CLOEXEC
*** ../vim-7.2.299/src/configure.in	2009-11-17 12:08:48.000000000 +0100
--- src/configure.in	2009-11-17 13:01:36.000000000 +0100
***************
*** 2855,2860 ****
--- 2855,2870 ----
    AC_MSG_RESULT(yes)
  fi
  
+ dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
+ AC_MSG_CHECKING(for FD_CLOEXEC)
+ AC_TRY_COMPILE(
+ [#if HAVE_FCNTL_H
+ # include <fcntl.h>
+ #endif],
+ [	int flag = FD_CLOEXEC;],
+ 	AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
+ 	AC_MSG_RESULT(not usable))
+ 
  dnl rename needs to be checked separately to work on Nextstep with cc
  AC_MSG_CHECKING(for rename)
  AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
*** ../vim-7.2.299/src/fileio.c	2009-11-17 14:57:19.000000000 +0100
--- src/fileio.c	2009-11-17 13:22:06.000000000 +0100
***************
*** 2254,2259 ****
--- 2254,2267 ----
  
      if (!read_buffer && !read_stdin)
  	close(fd);				/* errors are ignored */
+ #ifdef HAVE_FD_CLOEXEC
+     else
+     {
+ 	int fdflags = fcntl(fd, F_GETFD);
+ 	if (fdflags >= 0 && (fdflags & FD_CLOEXEC) == 0)
+ 	    fcntl(fd, F_SETFD, fdflags | FD_CLOEXEC);
+     }
+ #endif
      vim_free(buffer);
  
  #ifdef HAVE_DUP
*** ../vim-7.2.299/src/memfile.c	2008-07-13 19:39:39.000000000 +0200
--- src/memfile.c	2009-11-17 13:22:15.000000000 +0100
***************
*** 1343,1348 ****
--- 1343,1353 ----
      }
      else
      {
+ #ifdef HAVE_FD_CLOEXEC
+ 	int fdflags = fcntl(mfp->mf_fd, F_GETFD);
+ 	if (fdflags >= 0 && (fdflags & FD_CLOEXEC) == 0)
+ 	    fcntl(mfp->mf_fd, F_SETFD, fdflags | FD_CLOEXEC);
+ #endif
  #ifdef HAVE_SELINUX
  	mch_copy_sec(fname, mfp->mf_fname);
  #endif
*** ../vim-7.2.299/src/memline.c	2009-11-03 15:32:58.000000000 +0100
--- src/memline.c	2009-11-17 13:21:40.000000000 +0100
***************
*** 382,388 ****
      dp->db_index[0] = --dp->db_txt_start;	/* at end of block */
      dp->db_free -= 1 + INDEX_SIZE;
      dp->db_line_count = 1;
!     *((char_u *)dp + dp->db_txt_start) = NUL;	/* emtpy line */
  
      return OK;
  
--- 382,388 ----
      dp->db_index[0] = --dp->db_txt_start;	/* at end of block */
      dp->db_free -= 1 + INDEX_SIZE;
      dp->db_line_count = 1;
!     *((char_u *)dp + dp->db_txt_start) = NUL;	/* empty line */
  
      return OK;
  
***************
*** 490,495 ****
--- 490,502 ----
  	    EMSG(_("E301: Oops, lost the swap file!!!"));
  	    return;
  	}
+ #ifdef HAVE_FD_CLOEXEC
+ 	{
+ 	    int fdflags = fcntl(mfp->mf_fd, F_GETFD);
+ 	    if (fdflags >= 0 && (fdflags & FD_CLOEXEC) == 0)
+ 		fcntl(mfp->mf_fd, F_SETFD, fdflags | FD_CLOEXEC);
+ 	}
+ #endif
      }
      if (!success)
  	EMSG(_("E302: Could not rename swap file"));
*** ../vim-7.2.299/src/version.c	2009-11-17 16:08:12.000000000 +0100
--- src/version.c	2009-11-17 17:09:43.000000000 +0100
***************
*** 683,684 ****
--- 683,686 ----
  {   /* Add new patch number below this line */
+ /**/
+     300,
  /**/

-- 
            |

Ceci n'est pas une pipe.

 /// 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    ///