Skip to content

Commit c26648e

Browse files
dfrhaircommander
authored andcommitted
Fix close_other_fds on FreeBSD
While testing podman's restart policy handling, I noticed that containers which were publishing ports did not restart automatically. This was caused by conmon not properly closing the file descriptor which reserved the published port on the host before cleaning up the container. This commit lets conmon discover any extra file descriptors on FreeBSD. Signed-off-by: Doug Rabson <[email protected]>
1 parent ebc6717 commit c26648e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/close_fds.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222

2323
#include <sys/stat.h>
2424

25+
#ifdef __FreeBSD__
26+
#define OPEN_FILES_DIR "/dev/fd"
27+
#else
28+
#define OPEN_FILES_DIR "/proc/self/fd"
29+
#endif
30+
2531
static int open_files_max_fd;
2632
static fd_set *open_files_set;
2733

@@ -31,7 +37,7 @@ static void __attribute__((constructor)) init()
3137
ssize_t size = 0;
3238
DIR *d;
3339

34-
d = opendir("/proc/self/fd");
40+
d = opendir(OPEN_FILES_DIR);
3541
if (!d)
3642
return;
3743

@@ -85,7 +91,7 @@ void close_all_fds_ge_than(int firstfd)
8591
struct dirent *ent;
8692
DIR *d;
8793

88-
d = opendir("/proc/self/fd");
94+
d = opendir(OPEN_FILES_DIR);
8995
if (!d)
9096
return;
9197

0 commit comments

Comments
 (0)