Skip to content

Commit

Permalink
Added missing bracers in native code
Browse files Browse the repository at this point in the history
Contributed by STMicroelectronics

Signed-off-by: Torbjörn Svensson <[email protected]>
  • Loading branch information
Torbjorn-Svensson committed Aug 13, 2024
1 parent 6ffa029 commit 54ebddc
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 4 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
12 changes: 8 additions & 4 deletions core/org.eclipse.cdt.core.native/native_src/unix/exec_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ static int close_all_fds_using_parsing(unsigned int from_fd_inclusive) {
#endif

DIR *dirp = opendir(FD_DIR);
if (dirp == NULL)
if (dirp == NULL) {
return -1;
}

struct dirent *direntp;

Expand All @@ -75,19 +76,22 @@ static int close_all_fds_using_parsing(unsigned int from_fd_inclusive) {

static void close_all_fds_fallback(unsigned int from_fd_inclusive) {
int fdlimit = sysconf(_SC_OPEN_MAX);
if (fdlimit == -1)
if (fdlimit == -1) {
fdlimit = 65535; // arbitrary default, just in case
}
for (int fd = from_fd_inclusive; fd < fdlimit; fd++) {
close(fd);
}
}

static void close_all_fds() {
unsigned int from_fd = STDERR_FILENO + 1;
if (sys_close_range_wrapper(from_fd) == 0)
if (sys_close_range_wrapper(from_fd) == 0) {
return;
if (close_all_fds_using_parsing(from_fd) == 0)
}
if (close_all_fds_using_parsing(from_fd) == 0) {
return;
}
close_all_fds_fallback(from_fd);
}

Expand Down

0 comments on commit 54ebddc

Please sign in to comment.