mirror of
https://github.com/zeromq/libzmq.git
synced 2025-11-13 20:37:32 +01:00
Problem: tweetnacl leaks file descriptor on fork+exec
Solution: open with O_CLOEXEC if available or set FD_CLOEXEC if not
This commit is contained in:
25
acinclude.m4
25
acinclude.m4
@@ -614,6 +614,31 @@ int main (int argc, char *argv [])
|
||||
AS_IF([test "x$libzmq_cv_sock_cloexec" = "xyes"], [$1], [$2])
|
||||
}])
|
||||
|
||||
dnl ################################################################################
|
||||
dnl # LIBZMQ_CHECK_O_CLOEXEC([action-if-found], [action-if-not-found]) #
|
||||
dnl # Check if O_CLOEXEC is supported #
|
||||
dnl ################################################################################
|
||||
AC_DEFUN([LIBZMQ_CHECK_O_CLOEXEC], [{
|
||||
AC_CACHE_CHECK([whether O_CLOEXEC is supported], [libzmq_cv_o_cloexec],
|
||||
[AC_TRY_RUN([/* O_CLOEXEC test */
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
int main (int argc, char *argv [])
|
||||
{
|
||||
int s = open ("/dev/null", O_CLOEXEC | O_RDONLY);
|
||||
return (s == -1);
|
||||
}
|
||||
],
|
||||
[libzmq_cv_o_cloexec="yes"],
|
||||
[libzmq_cv_o_cloexec="no"],
|
||||
[libzmq_cv_o_cloexec="not during cross-compile"]
|
||||
)]
|
||||
)
|
||||
AS_IF([test "x$libzmq_cv_o_cloexec" = "xyes"], [$1], [$2])
|
||||
}])
|
||||
|
||||
dnl ################################################################################
|
||||
dnl # LIBZMQ_CHECK_EVENTFD_CLOEXEC([action-if-found], [action-if-not-found]) #
|
||||
dnl # Check if EFD_CLOEXEC is supported #
|
||||
|
||||
Reference in New Issue
Block a user