aboutsummaryrefslogtreecommitdiffstats
path: root/nt
diff options
context:
space:
mode:
authorPaul Eggert2013-07-07 11:00:14 -0700
committerPaul Eggert2013-07-07 11:00:14 -0700
commit067428c1717acd28f205c2cff93f0583eb347f4c (patch)
tree5937b119187f9900840e2c1174b408e86bb8d12b /nt
parent9aff9b3864085addb02b699f9648e547a8c00e54 (diff)
downloademacs-067428c1717acd28f205c2cff93f0583eb347f4c.tar.gz
emacs-067428c1717acd28f205c2cff93f0583eb347f4c.zip
Make file descriptors close-on-exec when possible.
This simplifies Emacs a bit, since it no longer needs to worry about closing file descriptors by hand in some cases. It also fixes some unlikely races. Not all such races, as libraries often open files internally without setting close-on-exec, but it's an improvement. * admin/merge-gnulib (GNULIB_MODULES): Add fcntl, pipe2. (GNULIB_TOOL_FLAGS): Avoid binary-io, close. Do not avoid fcntl. * configure.ac (mkostemp): New function to check for. (PTY_OPEN): Pass O_CLOEXEC to posix_openpt. * lib/fcntl.c, lib/getdtablesize.c, lib/pipe2.c, m4/fcntl.m4: * m4/getdtablesize.m4, m4/pipe2.m4: New files, taken from gnulib. * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate. * nt/gnulib.mk: Remove empty gl_GNULIB_ENABLED_verify section; otherwise, gnulib-tool complains given close-on-exec changes. * nt/inc/ms-w32.h (pipe): Remove. * nt/mingw-cfg.site (ac_cv_func_fcntl, gl_cv_func_fcntl_f_dupfd_cloexec) (gl_cv_func_fcntl_f_dupfd_works, ac_cv_func_pipe2): New vars. * src/alloc.c (valid_pointer_p) [!WINDOWSNT]: * src/callproc.c (Fcall_process) [!MSDOS]: * src/emacs.c (main) [!DOS_NT]: * src/nsterm.m (ns_term_init): * src/process.c (create_process): Use 'pipe2' with O_CLOEXEC instead of 'pipe'. * src/emacs.c (Fcall_process_region) [HAVE_MKOSTEMP]: * src/filelock.c (create_lock_file) [HAVE_MKOSTEMP]: Prefer mkostemp with O_CLOEXEC to mkstemp. * src/callproc.c (relocate_fd) [!WINDOWSNT]: * src/emacs.c (main): Use F_DUPFD_CLOEXEC, not plain F_DUPFD. No need to use fcntl (..., F_SETFD, FD_CLOEXEC), since we're now using pipe2. * src/filelock.c (create_lock_file) [! HAVE_MKOSTEMP]: Make the resulting file descriptor close-on-exec. * src/lisp.h, src/lread.c, src/process.c (close_load_descs, close_process_descs): * src/lread.c (load_descriptor_list, load_descriptor_unwind): Remove; no longer needed. All uses removed. * src/process.c (SOCK_CLOEXEC): Define to 0 if not supplied by system. (close_on_exec, accept4, process_socket) [!SOCK_CLOEXEC]: New functions. (socket) [!SOCK_CLOEXEC]: Supply a substitute. (Fmake_network_process, Fnetwork_interface_list): (Fnetwork_interface_info, server_accept_connection): Make newly-created socket close-on-exec. * src/sysdep.c (emacs_open, emacs_fopen): Make new-created descriptor close-on-exec. * src/w32.c (fcntl): Support F_DUPFD_CLOEXEC well enough for Emacs. * src/w32.c, src/w32.h (pipe2): Rename from 'pipe', with new flags arg. Fixes: debbugs:14803
Diffstat (limited to 'nt')
-rw-r--r--nt/ChangeLog9
-rw-r--r--nt/gnulib.mk3
-rw-r--r--nt/inc/ms-w32.h1
-rw-r--r--nt/mingw-cfg.site5
4 files changed, 14 insertions, 4 deletions
diff --git a/nt/ChangeLog b/nt/ChangeLog
index 1a0746b3181..a9b4f836644 100644
--- a/nt/ChangeLog
+++ b/nt/ChangeLog
@@ -1,3 +1,12 @@
12013-07-07 Paul Eggert <eggert@cs.ucla.edu>
2
3 Make file descriptors close-on-exec when possible (Bug#14803).
4 * gnulib.mk: Remove empty gl_GNULIB_ENABLED_verify section;
5 otherwise, gnulib-tool complains given close-on-exec changes.
6 * inc/ms-w32.h (pipe): Remove.
7 * mingw-cfg.site (ac_cv_func_fcntl, gl_cv_func_fcntl_f_dupfd_cloexec)
8 (gl_cv_func_fcntl_f_dupfd_works, ac_cv_func_pipe2): New vars.
9
12013-06-25 Juanma Barranquero <lekktu@gmail.com> 102013-06-25 Juanma Barranquero <lekktu@gmail.com>
2 11
3 * configure.bat: Add warning to the help text about using the 12 * configure.bat: Add warning to the help text about using the
diff --git a/nt/gnulib.mk b/nt/gnulib.mk
index ac4fc2768d9..df27dcf610c 100644
--- a/nt/gnulib.mk
+++ b/nt/gnulib.mk
@@ -876,9 +876,6 @@ EXTRA_DIST += utimens.h
876 876
877## begin gnulib module verify 877## begin gnulib module verify
878 878
879if gl_GNULIB_ENABLED_verify
880
881endif
882EXTRA_DIST += verify.h 879EXTRA_DIST += verify.h
883 880
884## end gnulib module verify 881## end gnulib module verify
diff --git a/nt/inc/ms-w32.h b/nt/inc/ms-w32.h
index 29c8e383893..3e50c78f145 100644
--- a/nt/inc/ms-w32.h
+++ b/nt/inc/ms-w32.h
@@ -211,7 +211,6 @@ extern struct tm * sys_localtime (const time_t *);
211#define mktemp sys_mktemp 211#define mktemp sys_mktemp
212#undef open 212#undef open
213#define open sys_open 213#define open sys_open
214#define pipe sys_pipe
215#undef read 214#undef read
216#define read sys_read 215#define read sys_read
217#define rename sys_rename 216#define rename sys_rename
diff --git a/nt/mingw-cfg.site b/nt/mingw-cfg.site
index 41e4f23784e..cf55fe04ed8 100644
--- a/nt/mingw-cfg.site
+++ b/nt/mingw-cfg.site
@@ -67,6 +67,10 @@ gl_cv_func_readlink_works=yes
67gl_cv_func_symlink_works=yes 67gl_cv_func_symlink_works=yes
68ac_cv_func_readlinkat=yes 68ac_cv_func_readlinkat=yes
69ac_cv_func_faccessat=yes 69ac_cv_func_faccessat=yes
70# Implemented in w32.c
71ac_cv_func_fcntl=yes
72gl_cv_func_fcntl_f_dupfd_cloexec=yes
73gl_cv_func_fcntl_f_dupfd_works=yes
70# We don't need fdopendir 74# We don't need fdopendir
71ac_cv_func_fdopendir="not-needed" 75ac_cv_func_fdopendir="not-needed"
72gl_cv_func_fdopendir_works="no-but-not-needed-so-yes" 76gl_cv_func_fdopendir_works="no-but-not-needed-so-yes"
@@ -95,6 +99,7 @@ ac_cv_func_getloadavg=yes
95# Avoid compiling gnulib mktime 99# Avoid compiling gnulib mktime
96gl_cv_func_working_mktime=yes 100gl_cv_func_working_mktime=yes
97# Implemented in w32.c 101# Implemented in w32.c
102ac_cv_func_pipe2=yes
98ac_cv_have_decl_unsetenv=yes 103ac_cv_have_decl_unsetenv=yes
99ac_cv_func_unsetenv=yes 104ac_cv_func_unsetenv=yes
100gt_cv_func_unsetenv_ret='int' 105gt_cv_func_unsetenv_ret='int'