Transferring stream handle between threads (e.g. detaching/reopening file descriptor)

24 views
Skip to first unread message

Eugene Ostroukhov

unread,
Jul 3, 2019, 2:06:07 AM7/3/19
to libuv
I saw discussion here: https://github.com/libuv/libuv/issues/390 and it looks like there's no universal way of transferring a handle between event loops.

Is there a way to close a handle without closing the file descriptor? 

What I want to do, is in Node.js code to get a handle from the main context and pass it into the inspector background thread. This handle would be something like a TCP socket or pipe - not a timer, async or such. It looks like I can get FD from the main thread and then use uv_tcp_open or alike on a background thread to "reopen" it. My main concern would be that the main thread will still consider it open and I expect there will be some issues.

Any suggestions?

Santiago Gimeno

unread,
Jul 3, 2019, 5:11:41 AM7/3/19
to li...@googlegroups.com
What about dup() the fd, then close the handle and open the duplicated fd with uv_tcp_open?

--
You received this message because you are subscribed to the Google Groups "libuv" group.
To unsubscribe from this group and stop receiving emails from it, send an email to libuv+un...@googlegroups.com.
To post to this group, send email to li...@googlegroups.com.
Visit this group at https://groups.google.com/group/libuv.
To view this discussion on the web visit https://groups.google.com/d/msgid/libuv/af04cbf6-e3a3-43af-a08c-0fbbe9e2ae06%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Eugene Ostroukhov

unread,
Jul 3, 2019, 9:43:36 AM7/3/19
to li...@googlegroups.com
Yes, I’ll try that.

You received this message because you are subscribed to a topic in the Google Groups "libuv" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/libuv/Nq99BPoYNOI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to libuv+un...@googlegroups.com.

To post to this group, send email to li...@googlegroups.com.
Visit this group at https://groups.google.com/group/libuv.
Reply all
Reply to author
Forward
0 new messages