Changing the test code of by adding a zmq_connect, the attached code leaks 2 windows file handles per second.
Windows Platform
If I move the server_sock creation and bind inside the loop, I don't observe any more leak.
This bug may not be limited to win32 as it seems to me that the leak occurs at a higher level than within signaler.cpp.
I have tested it on Linux and can confirm that a file descriptor leak occurs there too, observed by running the following command periodically:
ls /proc/$(pidof a.out)/fd | wc -w
The leak only occurs for inproc transport.
I tried adding some printfs to the library to see what was happening. A pipe_term is sent but somehow the receiving end does not get the message.
Proper cleanup does occur if the server socket also gets closed.
Found that if I send and receive some data, the leak doesn't occur.
This issue still occurs at 4.0.3. It is now tracked at github: https://github.com/zeromq/libzmq/issues/792