|
Karsten Hopp |
b17b6c |
To: vim-dev@vim.org
|
|
Karsten Hopp |
b17b6c |
Subject: Patch 7.2.300
|
|
Karsten Hopp |
b17b6c |
Fcc: outbox
|
|
Karsten Hopp |
b17b6c |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
b17b6c |
Mime-Version: 1.0
|
|
Karsten Hopp |
b17b6c |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
b17b6c |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
b17b6c |
------------
|
|
Karsten Hopp |
b17b6c |
|
|
Karsten Hopp |
b17b6c |
Patch 7.2.300
|
|
Karsten Hopp |
b17b6c |
Problem: Vim doesn't close file descriptors when forking and executing
|
|
Karsten Hopp |
b17b6c |
another command, e.g., ":shell".
|
|
Karsten Hopp |
b17b6c |
Solution: Use FD_CLOEXEC when available. (James Vega)
|
|
Karsten Hopp |
b17b6c |
Files: src/auto/configure, src/config.h.in, src/configure.in,
|
|
Karsten Hopp |
b17b6c |
src/ex_cmdds2.c, src/fileio.c, src/memfile.c, src/memline.c
|
|
Karsten Hopp |
b17b6c |
|
|
Karsten Hopp |
b17b6c |
|
|
Karsten Hopp |
b17b6c |
*** ../vim-7.2.299/src/auto/configure 2009-11-17 12:08:48.000000000 +0100
|
|
Karsten Hopp |
b17b6c |
--- src/auto/configure 2009-11-17 13:09:03.000000000 +0100
|
|
Karsten Hopp |
b17b6c |
***************
|
|
Karsten Hopp |
b17b6c |
*** 15174,15179 ****
|
|
Karsten Hopp |
b17b6c |
--- 15174,15231 ----
|
|
Karsten Hopp |
b17b6c |
$as_echo "yes" >&6; }
|
|
Karsten Hopp |
b17b6c |
fi
|
|
Karsten Hopp |
b17b6c |
|
|
Karsten Hopp |
b17b6c |
+ { $as_echo "$as_me:$LINENO: checking for FD_CLOEXEC" >&5
|
|
Karsten Hopp |
b17b6c |
+ $as_echo_n "checking for FD_CLOEXEC... " >&6; }
|
|
Karsten Hopp |
b17b6c |
+ cat >conftest.$ac_ext <<_ACEOF
|
|
Karsten Hopp |
b17b6c |
+ /* confdefs.h. */
|
|
Karsten Hopp |
b17b6c |
+ _ACEOF
|
|
Karsten Hopp |
b17b6c |
+ cat confdefs.h >>conftest.$ac_ext
|
|
Karsten Hopp |
b17b6c |
+ cat >>conftest.$ac_ext <<_ACEOF
|
|
Karsten Hopp |
b17b6c |
+ /* end confdefs.h. */
|
|
Karsten Hopp |
b17b6c |
+ #if HAVE_FCNTL_H
|
|
Karsten Hopp |
b17b6c |
+ # include <fcntl.h>
|
|
Karsten Hopp |
b17b6c |
+ #endif
|
|
Karsten Hopp |
b17b6c |
+ int
|
|
Karsten Hopp |
b17b6c |
+ main ()
|
|
Karsten Hopp |
b17b6c |
+ {
|
|
Karsten Hopp |
b17b6c |
+ int flag = FD_CLOEXEC;
|
|
Karsten Hopp |
b17b6c |
+ ;
|
|
Karsten Hopp |
b17b6c |
+ return 0;
|
|
Karsten Hopp |
b17b6c |
+ }
|
|
Karsten Hopp |
b17b6c |
+ _ACEOF
|
|
Karsten Hopp |
b17b6c |
+ rm -f conftest.$ac_objext
|
|
Karsten Hopp |
b17b6c |
+ if { (ac_try="$ac_compile"
|
|
Karsten Hopp |
b17b6c |
+ case "(($ac_try" in
|
|
Karsten Hopp |
b17b6c |
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
|
Karsten Hopp |
b17b6c |
+ *) ac_try_echo=$ac_try;;
|
|
Karsten Hopp |
b17b6c |
+ esac
|
|
Karsten Hopp |
b17b6c |
+ eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
|
|
Karsten Hopp |
b17b6c |
+ $as_echo "$ac_try_echo") >&5
|
|
Karsten Hopp |
b17b6c |
+ (eval "$ac_compile") 2>conftest.er1
|
|
Karsten Hopp |
b17b6c |
+ ac_status=$?
|
|
Karsten Hopp |
b17b6c |
+ grep -v '^ *+' conftest.er1 >conftest.err
|
|
Karsten Hopp |
b17b6c |
+ rm -f conftest.er1
|
|
Karsten Hopp |
b17b6c |
+ cat conftest.err >&5
|
|
Karsten Hopp |
b17b6c |
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
|
Karsten Hopp |
b17b6c |
+ (exit $ac_status); } && {
|
|
Karsten Hopp |
b17b6c |
+ test -z "$ac_c_werror_flag" ||
|
|
Karsten Hopp |
b17b6c |
+ test ! -s conftest.err
|
|
Karsten Hopp |
b17b6c |
+ } && test -s conftest.$ac_objext; then
|
|
Karsten Hopp |
b17b6c |
+ { $as_echo "$as_me:$LINENO: result: yes" >&5
|
|
Karsten Hopp |
b17b6c |
+ $as_echo "yes" >&6; }; cat >>confdefs.h <<\_ACEOF
|
|
Karsten Hopp |
b17b6c |
+ #define HAVE_FD_CLOEXEC 1
|
|
Karsten Hopp |
b17b6c |
+ _ACEOF
|
|
Karsten Hopp |
b17b6c |
+
|
|
Karsten Hopp |
b17b6c |
+ else
|
|
Karsten Hopp |
b17b6c |
+ $as_echo "$as_me: failed program was:" >&5
|
|
Karsten Hopp |
b17b6c |
+ sed 's/^/| /' conftest.$ac_ext >&5
|
|
Karsten Hopp |
b17b6c |
+
|
|
Karsten Hopp |
b17b6c |
+ { $as_echo "$as_me:$LINENO: result: not usable" >&5
|
|
Karsten Hopp |
b17b6c |
+ $as_echo "not usable" >&6; }
|
|
Karsten Hopp |
b17b6c |
+ fi
|
|
Karsten Hopp |
b17b6c |
+
|
|
Karsten Hopp |
b17b6c |
+ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
|
Karsten Hopp |
b17b6c |
+
|
|
Karsten Hopp |
b17b6c |
{ $as_echo "$as_me:$LINENO: checking for rename" >&5
|
|
Karsten Hopp |
b17b6c |
$as_echo_n "checking for rename... " >&6; }
|
|
Karsten Hopp |
b17b6c |
cat >conftest.$ac_ext <<_ACEOF
|
|
Karsten Hopp |
b17b6c |
*** ../vim-7.2.299/src/config.h.in 2009-11-17 12:08:48.000000000 +0100
|
|
Karsten Hopp |
b17b6c |
--- src/config.h.in 2009-11-17 13:01:36.000000000 +0100
|
|
Karsten Hopp |
b17b6c |
***************
|
|
Karsten Hopp |
b17b6c |
*** 388,390 ****
|
|
Karsten Hopp |
b17b6c |
--- 388,393 ----
|
|
Karsten Hopp |
b17b6c |
|
|
Karsten Hopp |
b17b6c |
/* Define if you want XSMP interaction as well as vanilla swapfile safety */
|
|
Karsten Hopp |
b17b6c |
#undef USE_XSMP_INTERACT
|
|
Karsten Hopp |
b17b6c |
+
|
|
Karsten Hopp |
b17b6c |
+ /* Define if fcntl()'s F_SETFD command knows about FD_CLOEXEC */
|
|
Karsten Hopp |
b17b6c |
+ #undef HAVE_FD_CLOEXEC
|
|
Karsten Hopp |
b17b6c |
*** ../vim-7.2.299/src/configure.in 2009-11-17 12:08:48.000000000 +0100
|
|
Karsten Hopp |
b17b6c |
--- src/configure.in 2009-11-17 13:01:36.000000000 +0100
|
|
Karsten Hopp |
b17b6c |
***************
|
|
Karsten Hopp |
b17b6c |
*** 2855,2860 ****
|
|
Karsten Hopp |
b17b6c |
--- 2855,2870 ----
|
|
Karsten Hopp |
b17b6c |
AC_MSG_RESULT(yes)
|
|
Karsten Hopp |
b17b6c |
fi
|
|
Karsten Hopp |
b17b6c |
|
|
Karsten Hopp |
b17b6c |
+ dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
|
|
Karsten Hopp |
b17b6c |
+ AC_MSG_CHECKING(for FD_CLOEXEC)
|
|
Karsten Hopp |
b17b6c |
+ AC_TRY_COMPILE(
|
|
Karsten Hopp |
b17b6c |
+ [#if HAVE_FCNTL_H
|
|
Karsten Hopp |
b17b6c |
+ # include <fcntl.h>
|
|
Karsten Hopp |
b17b6c |
+ #endif],
|
|
Karsten Hopp |
b17b6c |
+ [ int flag = FD_CLOEXEC;],
|
|
Karsten Hopp |
b17b6c |
+ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
|
|
Karsten Hopp |
b17b6c |
+ AC_MSG_RESULT(not usable))
|
|
Karsten Hopp |
b17b6c |
+
|
|
Karsten Hopp |
b17b6c |
dnl rename needs to be checked separately to work on Nextstep with cc
|
|
Karsten Hopp |
b17b6c |
AC_MSG_CHECKING(for rename)
|
|
Karsten Hopp |
b17b6c |
AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
|
|
Karsten Hopp |
b17b6c |
*** ../vim-7.2.299/src/fileio.c 2009-11-17 14:57:19.000000000 +0100
|
|
Karsten Hopp |
b17b6c |
--- src/fileio.c 2009-11-17 13:22:06.000000000 +0100
|
|
Karsten Hopp |
b17b6c |
***************
|
|
Karsten Hopp |
b17b6c |
*** 2254,2259 ****
|
|
Karsten Hopp |
b17b6c |
--- 2254,2267 ----
|
|
Karsten Hopp |
b17b6c |
|
|
Karsten Hopp |
b17b6c |
if (!read_buffer && !read_stdin)
|
|
Karsten Hopp |
b17b6c |
close(fd); /* errors are ignored */
|
|
Karsten Hopp |
b17b6c |
+ #ifdef HAVE_FD_CLOEXEC
|
|
Karsten Hopp |
b17b6c |
+ else
|
|
Karsten Hopp |
b17b6c |
+ {
|
|
Karsten Hopp |
b17b6c |
+ int fdflags = fcntl(fd, F_GETFD);
|
|
Karsten Hopp |
b17b6c |
+ if (fdflags >= 0 && (fdflags & FD_CLOEXEC) == 0)
|
|
Karsten Hopp |
b17b6c |
+ fcntl(fd, F_SETFD, fdflags | FD_CLOEXEC);
|
|
Karsten Hopp |
b17b6c |
+ }
|
|
Karsten Hopp |
b17b6c |
+ #endif
|
|
Karsten Hopp |
b17b6c |
vim_free(buffer);
|
|
Karsten Hopp |
b17b6c |
|
|
Karsten Hopp |
b17b6c |
#ifdef HAVE_DUP
|
|
Karsten Hopp |
b17b6c |
*** ../vim-7.2.299/src/memfile.c 2008-07-13 19:39:39.000000000 +0200
|
|
Karsten Hopp |
b17b6c |
--- src/memfile.c 2009-11-17 13:22:15.000000000 +0100
|
|
Karsten Hopp |
b17b6c |
***************
|
|
Karsten Hopp |
b17b6c |
*** 1343,1348 ****
|
|
Karsten Hopp |
b17b6c |
--- 1343,1353 ----
|
|
Karsten Hopp |
b17b6c |
}
|
|
Karsten Hopp |
b17b6c |
else
|
|
Karsten Hopp |
b17b6c |
{
|
|
Karsten Hopp |
b17b6c |
+ #ifdef HAVE_FD_CLOEXEC
|
|
Karsten Hopp |
b17b6c |
+ int fdflags = fcntl(mfp->mf_fd, F_GETFD);
|
|
Karsten Hopp |
b17b6c |
+ if (fdflags >= 0 && (fdflags & FD_CLOEXEC) == 0)
|
|
Karsten Hopp |
b17b6c |
+ fcntl(mfp->mf_fd, F_SETFD, fdflags | FD_CLOEXEC);
|
|
Karsten Hopp |
b17b6c |
+ #endif
|
|
Karsten Hopp |
b17b6c |
#ifdef HAVE_SELINUX
|
|
Karsten Hopp |
b17b6c |
mch_copy_sec(fname, mfp->mf_fname);
|
|
Karsten Hopp |
b17b6c |
#endif
|
|
Karsten Hopp |
b17b6c |
*** ../vim-7.2.299/src/memline.c 2009-11-03 15:32:58.000000000 +0100
|
|
Karsten Hopp |
b17b6c |
--- src/memline.c 2009-11-17 13:21:40.000000000 +0100
|
|
Karsten Hopp |
b17b6c |
***************
|
|
Karsten Hopp |
b17b6c |
*** 382,388 ****
|
|
Karsten Hopp |
b17b6c |
dp->db_index[0] = --dp->db_txt_start; /* at end of block */
|
|
Karsten Hopp |
b17b6c |
dp->db_free -= 1 + INDEX_SIZE;
|
|
Karsten Hopp |
b17b6c |
dp->db_line_count = 1;
|
|
Karsten Hopp |
b17b6c |
! *((char_u *)dp + dp->db_txt_start) = NUL; /* emtpy line */
|
|
Karsten Hopp |
b17b6c |
|
|
Karsten Hopp |
b17b6c |
return OK;
|
|
Karsten Hopp |
b17b6c |
|
|
Karsten Hopp |
b17b6c |
--- 382,388 ----
|
|
Karsten Hopp |
b17b6c |
dp->db_index[0] = --dp->db_txt_start; /* at end of block */
|
|
Karsten Hopp |
b17b6c |
dp->db_free -= 1 + INDEX_SIZE;
|
|
Karsten Hopp |
b17b6c |
dp->db_line_count = 1;
|
|
Karsten Hopp |
b17b6c |
! *((char_u *)dp + dp->db_txt_start) = NUL; /* empty line */
|
|
Karsten Hopp |
b17b6c |
|
|
Karsten Hopp |
b17b6c |
return OK;
|
|
Karsten Hopp |
b17b6c |
|
|
Karsten Hopp |
b17b6c |
***************
|
|
Karsten Hopp |
b17b6c |
*** 490,495 ****
|
|
Karsten Hopp |
b17b6c |
--- 490,502 ----
|
|
Karsten Hopp |
b17b6c |
EMSG(_("E301: Oops, lost the swap file!!!"));
|
|
Karsten Hopp |
b17b6c |
return;
|
|
Karsten Hopp |
b17b6c |
}
|
|
Karsten Hopp |
b17b6c |
+ #ifdef HAVE_FD_CLOEXEC
|
|
Karsten Hopp |
b17b6c |
+ {
|
|
Karsten Hopp |
b17b6c |
+ int fdflags = fcntl(mfp->mf_fd, F_GETFD);
|
|
Karsten Hopp |
b17b6c |
+ if (fdflags >= 0 && (fdflags & FD_CLOEXEC) == 0)
|
|
Karsten Hopp |
b17b6c |
+ fcntl(mfp->mf_fd, F_SETFD, fdflags | FD_CLOEXEC);
|
|
Karsten Hopp |
b17b6c |
+ }
|
|
Karsten Hopp |
b17b6c |
+ #endif
|
|
Karsten Hopp |
b17b6c |
}
|
|
Karsten Hopp |
b17b6c |
if (!success)
|
|
Karsten Hopp |
b17b6c |
EMSG(_("E302: Could not rename swap file"));
|
|
Karsten Hopp |
b17b6c |
*** ../vim-7.2.299/src/version.c 2009-11-17 16:08:12.000000000 +0100
|
|
Karsten Hopp |
b17b6c |
--- src/version.c 2009-11-17 17:09:43.000000000 +0100
|
|
Karsten Hopp |
b17b6c |
***************
|
|
Karsten Hopp |
b17b6c |
*** 683,684 ****
|
|
Karsten Hopp |
b17b6c |
--- 683,686 ----
|
|
Karsten Hopp |
b17b6c |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
b17b6c |
+ /**/
|
|
Karsten Hopp |
b17b6c |
+ 300,
|
|
Karsten Hopp |
b17b6c |
/**/
|
|
Karsten Hopp |
b17b6c |
|
|
Karsten Hopp |
b17b6c |
--
|
|
Karsten Hopp |
b17b6c |
|
|
|
Karsten Hopp |
b17b6c |
|
|
Karsten Hopp |
b17b6c |
Ceci n'est pas une pipe.
|
|
Karsten Hopp |
b17b6c |
|
|
Karsten Hopp |
b17b6c |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
b17b6c |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
b17b6c |
\\\ download, build and distribute -- http://www.A-A-P.org ///
|
|
Karsten Hopp |
b17b6c |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|