1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-23 07:19:15 +00:00
emacs/m4
Paul Eggert 067428c171 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
2013-07-07 11:00:14 -07:00
..
00gnulib.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
acl.m4 Use Gnulib ACL implementation, for benefit of Solaris etc. 2013-05-07 14:34:03 -07:00
alloca.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
c-strtod.m4 Merge from gnulib. 2013-01-02 08:37:04 -08:00
clock_time.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
close-stream.m4 Merge from gnulib. 2013-01-02 08:37:04 -08:00
dirent_h.m4 Use fdopendir, fstatat and readlinkat, for efficiency. 2013-01-31 22:30:51 -08:00
dup2.m4 Merge from gnulib. 2013-01-02 08:37:04 -08:00
environ.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
errno_h.m4 Use Gnulib ACL implementation, for benefit of Solaris etc. 2013-05-07 14:34:03 -07:00
euidaccess.m4 Merge from gnulib. 2013-01-02 08:37:04 -08:00
execinfo.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
extensions.m4 Comment fix, to match Gnulib upstream copy. 2013-05-07 14:04:51 -07:00
extern-inline.m4 Merge from gnulib. 2013-07-01 16:43:19 -07:00
faccessat.m4 Merge from gnulib. 2013-01-02 08:37:04 -08:00
fcntl_h.m4 Merge from gnulib. 2013-01-02 08:37:04 -08:00
fcntl.m4 Make file descriptors close-on-exec when possible. 2013-07-07 11:00:14 -07:00
fdatasync.m4 File synchronization fixes. 2013-03-13 11:42:22 -07:00
fdopendir.m4 Use fdopendir, fstatat and readlinkat, for efficiency. 2013-01-31 22:30:51 -08:00
filemode.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
fpending.m4 Merge from gnulib. 2013-01-02 08:37:04 -08:00
fstatat.m4 Use fdopendir, fstatat and readlinkat, for efficiency. 2013-01-31 22:30:51 -08:00
fsync.m4 File synchronization fixes. 2013-03-13 11:42:22 -07:00
getdtablesize.m4 Make file descriptors close-on-exec when possible. 2013-07-07 11:00:14 -07:00
getgroups.m4 Merge from gnulib. 2013-01-02 08:37:04 -08:00
getloadavg.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
getopt.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
gettime.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
gettimeofday.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
gnulib-common.m4 Merge from gnulib. 2013-01-02 08:37:04 -08:00
gnulib-comp.m4 Make file descriptors close-on-exec when possible. 2013-07-07 11:00:14 -07:00
gnulib-tool.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
group-member.m4 Merge from gnulib. 2013-01-02 08:37:04 -08:00
include_next.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
inttypes.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
largefile.m4 Merge from gnulib. 2013-01-16 09:45:39 -08:00
longlong.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
lstat.m4 Merge from gnulib. 2013-01-02 08:37:04 -08:00
manywarnings.m4 Merge from gnulib. 2013-05-16 00:10:39 -07:00
md5.m4 Merge from gnulib. 2013-01-02 08:37:04 -08:00
memrchr.m4 Tune by using memchr and memrchr. 2013-02-11 15:37:18 -08:00
mktime.m4 Merge from gnulib. 2013-03-12 17:38:42 -07:00
multiarch.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
nocrash.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
off_t.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
pathmax.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
pipe2.m4 Make file descriptors close-on-exec when possible. 2013-07-07 11:00:14 -07:00
pselect.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
pthread_sigmask.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
putenv.m4 Merge from gnulib: putenv: port to Solaris 10. 2013-03-13 00:15:17 -07:00
readlink.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
readlinkat.m4 Use fdopendir, fstatat and readlinkat, for efficiency. 2013-01-31 22:30:51 -08:00
setenv.m4 Merge from gnulib. 2013-01-02 08:37:04 -08:00
sha1.m4 Merge from gnulib. 2013-01-02 08:37:04 -08:00
sha256.m4 Merge from gnulib. 2013-01-02 08:37:04 -08:00
sha512.m4 Merge from gnulib. 2013-01-02 08:37:04 -08:00
sig2str.m4 Merge from gnulib. 2013-01-02 08:37:04 -08:00
signal_h.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
socklen.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
ssize_t.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
st_dm_mode.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
stat-time.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
stat.m4 Merge from gnulib. 2013-01-02 08:37:04 -08:00
stdalign.m4 Merge from gnulib 2013-03-30 10:30:06 -07:00
stdarg.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
stdbool.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
stddef_h.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
stdint.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
stdio_h.m4 Merge from gnulib. 2013-01-02 08:37:04 -08:00
stdlib_h.m4 Merge from gnulib. 2013-02-08 15:37:17 -08:00
strftime.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
string_h.m4 Tune by using memchr and memrchr. 2013-02-11 15:37:18 -08:00
strtoimax.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
strtoll.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
strtoull.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
strtoumax.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
symlink.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
sys_select_h.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
sys_socket_h.m4 Merge from gnulib. 2013-01-02 08:37:04 -08:00
sys_stat_h.m4 Merge from gnulib. 2013-01-02 08:37:04 -08:00
sys_time_h.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
sys_types_h.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
time_h.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
time_r.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
timer_time.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
timespec.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
tm_gmtoff.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
unistd_h.m4 Merge from gnulib. 2013-01-02 08:37:04 -08:00
utimbuf.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
utimens.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
utimes.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00
warnings.m4 Merge from gnulib. 2013-05-16 00:10:39 -07:00
wchar_t.m4 Update copyright notices for 2013. 2013-01-01 09:11:05 +00:00