On 2016-03-19 05:29, Matt Harden wrote:
If you need to continue using the Listener after calling File on it and
passing it to a child process, you can Close the original listener,
create a new listener with FileListener (which sets the FD to
nonblocking again) and Close the File. What's the use case for this? I
would expect the parent process to stop using the listener after passing
it to a child.
I think the problem I started trying to solve in essence can be boiled
down to that I wanted to implement the traditional restart-pattern with
2 processes (one new takes over from a parent), but doing it within a
single process.
In other words I wanted to be able to call a function like
http.Serve(listener) two times without closing the listener.

Now... http.Serve() is very explicit that it insists on calling Close()
on the listener on exit.

So to avoid closing the TCP connection I needed to call dup(2) (via
File() ) on the Listener.
Unfortunately this sets the socket blocking.

When you do this with two processes (via os.StartProcess) everything is
taken care of by the stdlib.
But it seems impossible to do in a single process without manipulating
the file-descriptors via the syscall package.


You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 17 of 21 | next ›
Discussion Overview
groupgolang-nuts @
postedMar 16, '16 at 10:04a
activeMar 30, '16 at 10:56a



site design / logo © 2021 Grokbase