Skip to content

Commit ccb5064

Browse files
committed
Working on macros
1 parent 3a7b285 commit ccb5064

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

cbits/posix/bsd_closefrom.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef BSD_CLOSEFROM_H_
2+
#define BSD_CLOSEFROM_H_
3+
4+
void closefrom(int lowfd);
5+
6+
#endif // BSD_CLOSEFROM_H_

cbits/posix/common.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ struct std_handle {
2323
};
2424

2525
void closefrom_excluding(int from, int excluding);
26-
void closefrom(int lowfd);
2726

2827
// defined in find_executable.c
2928
#if !defined(HAVE_EXECVPE)

cbits/posix/runProcess.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include "runProcess.h"
88
#include "common.h"
99

10+
#include "bsd_closefrom.h"
11+
1012
#include <unistd.h>
1113
#include <errno.h>
1214
#include <sys/wait.h>
@@ -19,7 +21,8 @@
1921
#include <signal.h>
2022
#endif
2123

22-
#if defined(HAVE_CLOSE_RANGE)
24+
#if defined(HAVE_LINUX_CLOSE_RANGE_H)
25+
#define _GNU_SOURCE
2326
#include <linux/close_range.h>
2427
#endif
2528

configure.ac

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@ AC_CHECK_FUNCS([setitimer sysconf])
1717
AC_CHECK_FUNCS([execvpe])
1818

1919
# check for headers and functions used by bsd_closefrom.c
20-
AC_CHECK_HEADERS([dirent.h fcntl.h libproc.h ndir.h sys/dir.h sys/ndir.h])
21-
AC_CHECK_FUNCS([
22-
closefrom
23-
close_range
24-
dirfd
25-
proc_pid
26-
proc_pidinfo
27-
sysconf
28-
])
20+
AC_CHECK_HEADERS([dirent.h fcntl.h libproc.h linux/close_range.h ndir.h sys/dir.h sys/ndir.h])
21+
AC_CHECK_FUNCS([closefrom close_range dirfd proc_pidinfo sysconf])
22+
AC_MSG_CHECKING([for /proc/pid/fd directory])
23+
if test -d "/proc/$$/fd" ; then
24+
AC_DEFINE([HAVE_PROC_PID], [1], [Define if you have /proc/$pid/fd])
25+
AC_MSG_RESULT([yes])
26+
else
27+
AC_MSG_RESULT([no])
28+
fi
29+
2930

3031
# posix_spawn checks
3132
AC_CHECK_HEADERS([spawn.h])

0 commit comments

Comments
 (0)