You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
Activity
danielgindi commentedon Jul 17, 2018
Basically what I'm looking for is the inverse of
uv_get_osfhandlebzoz commentedon Jul 18, 2018
Duplicate of nodejs/node#15433?
bzoz commentedon Jul 18, 2018
i.e. are you looking for
uv_open_osfhandleto get implemented?danielgindi commentedon Jul 18, 2018
Exactly!
uv_open_osfhandle...danielgindi commentedon Jul 18, 2018
The thing is that the whole issue is about passing an
fdacross 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
fdyou can extract itsHANDLEand pass it on to an exporteduv_open_osfhandlefunction 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.
fs: add uv_open_osfhandle
fs: add uv_open_osfhandle
fs: add uv_open_osfhandle
deps: upgrade to libuv 1.23.0
deps: upgrade to libuv 1.23.0
deps: upgrade to libuv 1.23.0
bzoz commentedon Oct 11, 2018
Fixed by libuv/libuv#1927 included in nodejs/node#22365
danielgindi commentedon Oct 11, 2018
Yeah I already am enjoying this :-)