8000 Correct formatting of C code by jonahgraham · Pull Request #843 · eclipse-cdt/cdt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Correct formatting of C code #843

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
18 changes: 11 additions & 7 deletions core/org.eclipse.cdt.core.native/native_src/unix/exec_pty.c
EC77
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ extern char *pfind(const char *name, char *const envp[]);
static int sys_close_range_wrapper(unsigned int from_fd_inclusive) {
// Use fast `close_range` (https://man7.org/linux/man-pages/man2/close_range.2.html) if available.
// Cannot call `close_range` from libc, as it may be unavailable in older libc.
# if defined(__linux__) && defined(SYS_close_range) && defined(CLOSE_RANGE_UNSHARE)
#if defined(__linux__) && defined(SYS_close_range) && defined(CLOSE_RANGE_UNSHARE)
return syscall(SYS_close_range, from_fd_inclusive, ~0U, CLOSE_RANGE_UNSHARE);
# else
#else
errno = ENOSYS;
return -1;
# endif
#endif
}

static int close_all_fds_using_parsing(unsigned int from_fd_inclusive) {
Expand All @@ -57,7 +57,8 @@ static int close_all_fds_using_parsing(unsigned int from_fd_inclusive) {
#endif

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

struct dirent *direntp;

Expand All @@ -77,16 +78,19 @@ 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) fdlimit = 65535; // arbitrary default, just in case
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) return;
if (close_all_fds_using_parsing(from_fd) == 0) return;
if (sys_close_range_wrapper(from_fd) == 0)
return;
if (close_all_fds_using_parsing(from_fd) == 0)
return;
close_all_fds_fallback(from_fd);
}

Expand Down
Loading
0