GithubHelp home page GithubHelp logo

Comments (5)

nu774 avatar nu774 commented on July 27, 2024 1

the caller is responsible for handling errors.

Are you kidding? Because socket2 always forcibly adds SOCK_CLOSEXEC on Linux, the calling app has no way to retry without it.

Also what is WSL1?

https://learn.microsoft.com/en-us/windows/wsl/about

from socket2.

Thomasdezeeuw avatar Thomasdezeeuw commented on July 27, 2024

I don't think it it s a very good design to silently add a flag that the caller even didn't passed, then miserably fails because of that.

All file descriptor types in the standard library set the SOCK_CLOEXEC flag, it's expected of types outside of it as well.

If this library has to set SOCK_CLOEXEC flag, why don't you try socket(2) call again without it when it failed?

No, socket2 is a small wrapper around system calls, the caller is responsible for handling errors.

Also what is WSL1? I'm not even sure we support that platform. It would be nice if you explain what abbreviations are before using them.

Finally, have you tried Socket::new_raw? It's very clear from the Socket::new documentation what flags are set and it recommends Socket::new_raw in cases where those flags don't make sense.

from socket2.

Thomasdezeeuw avatar Thomasdezeeuw commented on July 27, 2024

Are you kidding? Because socket2 always forcibly adds SOCK_CLOSEXEC on Linux, the calling app has no way to retry without it.

Did you read my comment? Socket::new_raw.

Also what is WSL1?

https://learn.microsoft.com/en-us/windows/wsl/about

We support Windows, why not use that? If WSL1 doesn't support SOCK_CLOSEXEC, something quite crucial to Unix, it's not Linux.

from socket2.

the8472 avatar the8472 commented on July 27, 2024

Setting CLOEXEC on file descriptors is standard for pretty much every single feature that opens a file descriptor.
The socket manpage does not even list a compatibility note when SOCK_CLOEXEC was introduced, so it must have been there for a very long time.

If WSL1 does not support it then that is on WSL. Its spotty syscall-compatibility is a known issue and the reason why microsoft abandoned this approach and built WSL2 instead.
You could perhaps file a bug on the WSL issue tracker.

Are you even sure that it's because of that socket option? That seems to be fairly surprising to me because we also use it in the standard library. Can you provide an strace output (assuming that works on WSL1)?

from socket2.

nu774 avatar nu774 commented on July 27, 2024

Did you read my comment? Socket::new_raw.

Oh, I missed that part. Sorry.

Are you even sure that it's because of that socket option?

I found socket(2) was failing with -1 by exactly running via strace at my office.
A call to socket() shouldn't usually fail, and only suspicious thing I found was a SOCK_CLOEXEC flag.
However, now at home, I cannot reproduce it now by a simple C program (on a different PC).
I should look into this more, but anyway I'm closing this for now.
Sorry to have disturbed you.

from socket2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.