Merge from gnulib
This incorporates:
2016-01-24 openat_proc_name: fix last '/' overwritten on OS/2 kLIBC
2016-01-24 closedir, dirfd, opendir: port to OpenSolaris 5.10
2016-01-15 detect utimes() correctly on OS/2 kLIBC
2016-01-15 openat_proc_name: port to OS/2 kLIBC
2016-01-14 stdint: check _INTPTR_T_DECLARED for intptr_t etc.
2016-01-14 opendir, closedir, dirfd, fdopendir: port to OS/2 kLIBC
2016-01-14 dup, dup2, fcntl: support a directory fd on OS/2 kLIBC
2016-01-14 binary-io: don't put fd in binary mode if a console on EMX
2016-01-14 sig2str: list all signals on FreeBSD >= 7
2016-01-13 acl-permissions: port to USE_ACL==0 platforms
2016-01-12 mktime: rename macro to avoid glibc clash
2016-01-12 Port "$@" to OpenIndiana ksh93
2016-01-12 Port Universal Time settings to strict POSIX
* build-aux/gitlog-to-changelog, build-aux/update-copyright:
* doc/misc/texinfo.tex, lib/acl-internal.c, lib/acl-internal.h:
* lib/binary-io.h, lib/dirent.in.h, lib/dirfd.c, lib/dup2.c:
* lib/fcntl.c, lib/fdopendir.c, lib/mktime.c, lib/openat-proc.c:
* lib/sig2str.h, lib/stdint.in.h, m4/dirfd.m4, m4/dup2.m4:
* m4/fcntl.m4, m4/utimes.m4:
Copy from gnulib.
* m4/gnulib-comp.m4: Regenerate.
2016-01-24 22:50:47 +00:00
|
|
|
# fcntl.m4 serial 9
|
2017-01-01 03:14:01 +00:00
|
|
|
dnl Copyright (C) 2009-2017 Free Software Foundation, Inc.
|
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 18:00:14 +00:00
|
|
|
dnl This file is free software; the Free Software Foundation
|
|
|
|
dnl gives unlimited permission to copy and/or distribute it,
|
|
|
|
dnl with or without modifications, as long as this notice is preserved.
|
|
|
|
|
|
|
|
# For now, this module ensures that fcntl()
|
|
|
|
# - supports F_DUPFD correctly
|
|
|
|
# - supports or emulates F_DUPFD_CLOEXEC
|
|
|
|
# - supports F_GETFD
|
|
|
|
# Still to be ported to mingw:
|
|
|
|
# - F_SETFD
|
|
|
|
# - F_GETFL, F_SETFL
|
|
|
|
# - F_GETOWN, F_SETOWN
|
|
|
|
# - F_GETLK, F_SETLK, F_SETLKW
|
|
|
|
AC_DEFUN([gl_FUNC_FCNTL],
|
|
|
|
[
|
|
|
|
dnl Persuade glibc to expose F_DUPFD_CLOEXEC.
|
|
|
|
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
|
|
|
|
AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
|
|
|
|
AC_REQUIRE([AC_CANONICAL_HOST])
|
Merge from gnulib
* doc/misc/texinfo.tex: Update from gnulib.
* lib/getdtablesize.c, lib/getopt.c, lib/signal.in.h, lib/tempname.c:
* lib/tempname.h, m4/dup2.m4, m4/fcntl.m4, m4/getdtablesize.m4:
Update from gnulib, incorporating:
2015-02-20 getdtablesize: port better for Android
2015-02-19 fcntl: Fix cross compiling
2015-02-18 dup2, fcntl: cross-compile better for Android
2015-02-18 getopt: don't crash on memory exhaustion
2015-02-17 tempname: allow compilation with C++ (trivial)
2015-02-17 dup2, fcntl: port to AIX
2015-02-16 getdtablesize, dup2, fcntl: port to Android
2015-02-11 getdtablesize, signal_h: Fix Android build
2015-02-11 maint: various whitespace cleanups in tempname
2015-02-21 07:31:17 +00:00
|
|
|
AC_CHECK_FUNCS_ONCE([fcntl])
|
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 18:00:14 +00:00
|
|
|
if test $ac_cv_func_fcntl = no; then
|
|
|
|
gl_REPLACE_FCNTL
|
|
|
|
else
|
|
|
|
dnl cygwin 1.5.x F_DUPFD has wrong errno, and allows negative target
|
|
|
|
dnl haiku alpha 2 F_DUPFD has wrong errno
|
|
|
|
AC_CACHE_CHECK([whether fcntl handles F_DUPFD correctly],
|
|
|
|
[gl_cv_func_fcntl_f_dupfd_works],
|
Merge from gnulib
* doc/misc/texinfo.tex: Update from gnulib.
* lib/getdtablesize.c, lib/getopt.c, lib/signal.in.h, lib/tempname.c:
* lib/tempname.h, m4/dup2.m4, m4/fcntl.m4, m4/getdtablesize.m4:
Update from gnulib, incorporating:
2015-02-20 getdtablesize: port better for Android
2015-02-19 fcntl: Fix cross compiling
2015-02-18 dup2, fcntl: cross-compile better for Android
2015-02-18 getopt: don't crash on memory exhaustion
2015-02-17 tempname: allow compilation with C++ (trivial)
2015-02-17 dup2, fcntl: port to AIX
2015-02-16 getdtablesize, dup2, fcntl: port to Android
2015-02-11 getdtablesize, signal_h: Fix Android build
2015-02-11 maint: various whitespace cleanups in tempname
2015-02-21 07:31:17 +00:00
|
|
|
[AC_RUN_IFELSE(
|
|
|
|
[AC_LANG_PROGRAM(
|
|
|
|
[[#include <errno.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <sys/resource.h>
|
|
|
|
#include <unistd.h>
|
2015-02-25 00:38:16 +00:00
|
|
|
#ifndef RLIM_SAVED_CUR
|
|
|
|
# define RLIM_SAVED_CUR RLIM_INFINITY
|
|
|
|
#endif
|
|
|
|
#ifndef RLIM_SAVED_MAX
|
|
|
|
# define RLIM_SAVED_MAX RLIM_INFINITY
|
|
|
|
#endif
|
Merge from gnulib
* doc/misc/texinfo.tex: Update from gnulib.
* lib/getdtablesize.c, lib/getopt.c, lib/signal.in.h, lib/tempname.c:
* lib/tempname.h, m4/dup2.m4, m4/fcntl.m4, m4/getdtablesize.m4:
Update from gnulib, incorporating:
2015-02-20 getdtablesize: port better for Android
2015-02-19 fcntl: Fix cross compiling
2015-02-18 dup2, fcntl: cross-compile better for Android
2015-02-18 getopt: don't crash on memory exhaustion
2015-02-17 tempname: allow compilation with C++ (trivial)
2015-02-17 dup2, fcntl: port to AIX
2015-02-16 getdtablesize, dup2, fcntl: port to Android
2015-02-11 getdtablesize, signal_h: Fix Android build
2015-02-11 maint: various whitespace cleanups in tempname
2015-02-21 07:31:17 +00:00
|
|
|
]],
|
|
|
|
[[int result = 0;
|
|
|
|
int bad_fd = INT_MAX;
|
|
|
|
struct rlimit rlim;
|
|
|
|
if (getrlimit (RLIMIT_NOFILE, &rlim) == 0
|
|
|
|
&& 0 <= rlim.rlim_cur && rlim.rlim_cur <= INT_MAX
|
|
|
|
&& rlim.rlim_cur != RLIM_INFINITY
|
|
|
|
&& rlim.rlim_cur != RLIM_SAVED_MAX
|
|
|
|
&& rlim.rlim_cur != RLIM_SAVED_CUR)
|
|
|
|
bad_fd = rlim.rlim_cur;
|
|
|
|
if (fcntl (0, F_DUPFD, -1) != -1) result |= 1;
|
|
|
|
if (errno != EINVAL) result |= 2;
|
|
|
|
if (fcntl (0, F_DUPFD, bad_fd) != -1) result |= 4;
|
|
|
|
if (errno != EINVAL) result |= 8;
|
Merge from gnulib
This incorporates:
2016-01-24 openat_proc_name: fix last '/' overwritten on OS/2 kLIBC
2016-01-24 closedir, dirfd, opendir: port to OpenSolaris 5.10
2016-01-15 detect utimes() correctly on OS/2 kLIBC
2016-01-15 openat_proc_name: port to OS/2 kLIBC
2016-01-14 stdint: check _INTPTR_T_DECLARED for intptr_t etc.
2016-01-14 opendir, closedir, dirfd, fdopendir: port to OS/2 kLIBC
2016-01-14 dup, dup2, fcntl: support a directory fd on OS/2 kLIBC
2016-01-14 binary-io: don't put fd in binary mode if a console on EMX
2016-01-14 sig2str: list all signals on FreeBSD >= 7
2016-01-13 acl-permissions: port to USE_ACL==0 platforms
2016-01-12 mktime: rename macro to avoid glibc clash
2016-01-12 Port "$@" to OpenIndiana ksh93
2016-01-12 Port Universal Time settings to strict POSIX
* build-aux/gitlog-to-changelog, build-aux/update-copyright:
* doc/misc/texinfo.tex, lib/acl-internal.c, lib/acl-internal.h:
* lib/binary-io.h, lib/dirent.in.h, lib/dirfd.c, lib/dup2.c:
* lib/fcntl.c, lib/fdopendir.c, lib/mktime.c, lib/openat-proc.c:
* lib/sig2str.h, lib/stdint.in.h, m4/dirfd.m4, m4/dup2.m4:
* m4/fcntl.m4, m4/utimes.m4:
Copy from gnulib.
* m4/gnulib-comp.m4: Regenerate.
2016-01-24 22:50:47 +00:00
|
|
|
/* On OS/2 kLIBC, F_DUPFD does not work on a directory fd */
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
fd = open (".", O_RDONLY);
|
|
|
|
if (fd == -1)
|
|
|
|
result |= 16;
|
|
|
|
else if (fcntl (fd, F_DUPFD, STDERR_FILENO + 1) == -1)
|
|
|
|
result |= 32;
|
|
|
|
|
|
|
|
close (fd);
|
|
|
|
}
|
Merge from gnulib
* doc/misc/texinfo.tex: Update from gnulib.
* lib/getdtablesize.c, lib/getopt.c, lib/signal.in.h, lib/tempname.c:
* lib/tempname.h, m4/dup2.m4, m4/fcntl.m4, m4/getdtablesize.m4:
Update from gnulib, incorporating:
2015-02-20 getdtablesize: port better for Android
2015-02-19 fcntl: Fix cross compiling
2015-02-18 dup2, fcntl: cross-compile better for Android
2015-02-18 getopt: don't crash on memory exhaustion
2015-02-17 tempname: allow compilation with C++ (trivial)
2015-02-17 dup2, fcntl: port to AIX
2015-02-16 getdtablesize, dup2, fcntl: port to Android
2015-02-11 getdtablesize, signal_h: Fix Android build
2015-02-11 maint: various whitespace cleanups in tempname
2015-02-21 07:31:17 +00:00
|
|
|
return result;]])],
|
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 18:00:14 +00:00
|
|
|
[gl_cv_func_fcntl_f_dupfd_works=yes],
|
|
|
|
[gl_cv_func_fcntl_f_dupfd_works=no],
|
Merge from gnulib
* doc/misc/texinfo.tex: Update from gnulib.
* lib/getdtablesize.c, lib/getopt.c, lib/signal.in.h, lib/tempname.c:
* lib/tempname.h, m4/dup2.m4, m4/fcntl.m4, m4/getdtablesize.m4:
Update from gnulib, incorporating:
2015-02-20 getdtablesize: port better for Android
2015-02-19 fcntl: Fix cross compiling
2015-02-18 dup2, fcntl: cross-compile better for Android
2015-02-18 getopt: don't crash on memory exhaustion
2015-02-17 tempname: allow compilation with C++ (trivial)
2015-02-17 dup2, fcntl: port to AIX
2015-02-16 getdtablesize, dup2, fcntl: port to Android
2015-02-11 getdtablesize, signal_h: Fix Android build
2015-02-11 maint: various whitespace cleanups in tempname
2015-02-21 07:31:17 +00:00
|
|
|
[case $host_os in
|
|
|
|
aix* | cygwin* | haiku*)
|
|
|
|
gl_cv_func_fcntl_f_dupfd_works="guessing no" ;;
|
|
|
|
*) gl_cv_func_fcntl_f_dupfd_works="guessing yes" ;;
|
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 18:00:14 +00:00
|
|
|
esac])])
|
|
|
|
case $gl_cv_func_fcntl_f_dupfd_works in
|
|
|
|
*yes) ;;
|
|
|
|
*) gl_REPLACE_FCNTL
|
|
|
|
AC_DEFINE([FCNTL_DUPFD_BUGGY], [1], [Define this to 1 if F_DUPFD
|
|
|
|
behavior does not match POSIX]) ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
dnl Many systems lack F_DUPFD_CLOEXEC
|
|
|
|
AC_CACHE_CHECK([whether fcntl understands F_DUPFD_CLOEXEC],
|
|
|
|
[gl_cv_func_fcntl_f_dupfd_cloexec],
|
|
|
|
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
|
|
|
#include <fcntl.h>
|
|
|
|
#ifndef F_DUPFD_CLOEXEC
|
|
|
|
choke me
|
|
|
|
#endif
|
|
|
|
]])],
|
|
|
|
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
|
|
|
#ifdef __linux__
|
|
|
|
/* The Linux kernel only added F_DUPFD_CLOEXEC in 2.6.24, so we always replace
|
|
|
|
it to support the semantics on older kernels that failed with EINVAL. */
|
|
|
|
choke me
|
|
|
|
#endif
|
|
|
|
]])],
|
|
|
|
[gl_cv_func_fcntl_f_dupfd_cloexec=yes],
|
|
|
|
[gl_cv_func_fcntl_f_dupfd_cloexec="needs runtime check"])],
|
|
|
|
[gl_cv_func_fcntl_f_dupfd_cloexec=no])])
|
|
|
|
if test "$gl_cv_func_fcntl_f_dupfd_cloexec" != yes; then
|
|
|
|
gl_REPLACE_FCNTL
|
|
|
|
dnl No witness macro needed for this bug.
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
dnl Replace fcntl() for supporting the gnulib-defined fchdir() function,
|
|
|
|
dnl to keep fchdir's bookkeeping up-to-date.
|
|
|
|
m4_ifdef([gl_FUNC_FCHDIR], [
|
|
|
|
gl_TEST_FCHDIR
|
|
|
|
if test $HAVE_FCHDIR = 0; then
|
|
|
|
gl_REPLACE_FCNTL
|
|
|
|
fi
|
|
|
|
])
|
|
|
|
])
|
|
|
|
|
|
|
|
AC_DEFUN([gl_REPLACE_FCNTL],
|
|
|
|
[
|
|
|
|
AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
|
|
|
|
AC_CHECK_FUNCS_ONCE([fcntl])
|
|
|
|
if test $ac_cv_func_fcntl = no; then
|
|
|
|
HAVE_FCNTL=0
|
|
|
|
else
|
|
|
|
REPLACE_FCNTL=1
|
|
|
|
fi
|
|
|
|
])
|