Re: Closing an accepting BSD socket from a different thread

Marc Herbert

On 23 May 2019, at 00:10, Stephan Gatzka <stephan.gatzka@...> wrote:

I can't just send a signal to that thread which called poll() like it would work in Linux.

You're assuming Unix signals work... Unfixable designs

variables. E.g., following is a well-know pattern:
=== main loop thread ===
while (!should_exit) {
poll(..., MAIN_LOOP_PERIOD);
=== other threads ===
should_exit = true;
Yeah sure, put this is polling and a waste of resources.
Even if MAIN_LOOP_PERIOD is somewhat longer than the network protocol timeout(s) after which the socket should be closed anyway if the other end disappears?

No, the only possible solution I see is an additional socket connection via localhost which "signals" poll() and afterwards I can see what needs to be done (e.g. calling close()).

Join to automatically receive all group messages.