Skip to content
New issue

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

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

Already on GitHub? # to your account

Make the difference between cfg(target_os = "macos") and cfg(not(target_os = "linux")) clearer #122

Open
liubin opened this issue Dec 21, 2021 · 1 comment
Assignees

Comments

@liubin
Copy link
Collaborator

liubin commented Dec 21, 2021

There are two types of checking different OSs:

#[cfg(not(target_os = "linux"))]
let fds = {
let (rfd, wfd) = pipe()?;
set_fd_close_exec(rfd)?;
set_fd_close_exec(wfd)?;
(rfd, wfd)
};

ttrpc-rust/src/common.rs

Lines 120 to 123 in dfae1ad

// MacOS doesn't support atomic creation of a socket descriptor with SOCK_CLOEXEC flag,
// so there is a chance of leak if fork + exec happens in between of these calls.
#[cfg(target_os = "macos")]
set_fd_close_exec(fd)?;

Should these use the consistent way, for example, the pairs of:

  • target_os = "linux" and target_os = "macos"
  • target_os = "linux" and not(target_os = "linux")
@mxpv
Copy link
Member

mxpv commented Dec 28, 2021

I think this partially intersects with #132
SOCK_CLOEXEC fix applicable to both windows and mac os, so it make sense to use not(linux) or any(windows, macos).

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants