Skip to content

A way to pass a file descriptor to Node? #304

Description

@danielgindi

As compiling a NAPI module results in a library with a separate CRT, the state containing the FD table is different.
So if I have a situation where I have a HANDLE or an FD that I want to pass to Node - I find it problematic right now.
There's no API to accept a Windows' HANDLE, and no api to duplicate an FD into Node's namespace.

Anyone knows of a way to do that?

Thank you!

Activity

  1. danielgindi commented on Jul 17, 2018

    @danielgindi
    Author

    Basically what I'm looking for is the inverse of uv_get_osfhandle

  2. bzoz commented on Jul 18, 2018

    @bzoz

    Duplicate of nodejs/node#15433?

  3. bzoz commented on Jul 18, 2018

    @bzoz

    i.e. are you looking for uv_open_osfhandle to get implemented?

  4. danielgindi commented on Jul 18, 2018

    @danielgindi
    Author

    Exactly! uv_open_osfhandle...

  5. danielgindi commented on Jul 18, 2018

    @danielgindi
    Author

    The thing is that the whole issue is about passing an fd across modules, which is not possible in most cases due to separate CRTs (even if you recompile node.exe with msvcrt.dll, you must compile against the same version...)

    But if have a fd you can extract its HANDLE and pass it on to an exported uv_open_osfhandle function which will re-wrap it in its own CRT state.

    So right now it's possible to get an FD from node and use it in a native addon, but not vice versa.

  6. added a commit that references this issue on Jul 19, 2018
  7. added a commit that references this issue on Aug 1, 2018
  8. added a commit that references this issue on Aug 9, 2018
  9. added a commit that references this issue on Aug 20, 2018
  10. added a commit that references this issue on Aug 21, 2018
  11. added a commit that references this issue on Sep 3, 2018
  12. bzoz commented on Oct 11, 2018

    @bzoz

    Fixed by libuv/libuv#1927 included in nodejs/node#22365

  13. danielgindi commented on Oct 11, 2018

    @danielgindi
    Author

    Yeah I already am enjoying this :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions