NN_TERM(3)
π NN_TERM(3) π
okay bestie, gather round, because this is the nanomsg nn_term page β manual section 3, from nanomsg 1.2.2 β and it's literally the "everybody get out of the pool" function π«Ά
β¨ NAME β¨
nn_term β notify all sockets about process termination
πΈ SYNOPSIS πΈ
#include <nanomsg/nn.h>
void nn_term (void);
like. that's it. no args. no return value. she just does things π
π¦ DESCRIPTION π¦
So here's the vibe: shutting down multi-threaded programs is lowkey a nightmare, and nanomsg said "not on my watch." Enter nn_term(), the icon herself. She closes all open sockets and releases all related resources. Boom. Cleaned up. Main character energy, no cap.
Now the spicy part π₯ If a socket is blocked inside a blocking function β think nn_recv(3) β it will get unblocked, and an EBADF error gets returned to you. And not just that one time, bestie: subsequent calls on such sockets will also return EBADF. She's done. She's not coming back. Respect it.
And if you try to open a new socket with nn_socket(3) after termination? Yeah no. You get an ETERM error. The door is closed, the lights are off, the party is over π
One more thing, and this one's important if you're out here polling: if you're waiting for NN_SNDFD or NN_RCVFD using a polling function like poll() or select(), that call will unblock with both NN_SNDFD and NN_RCVFD signaled. Both of them. Not one. Both. It's giving "we're ALL leaving together" β¨
π EXAMPLE π
s = nn_socket (AF_SP, NN_PAIR);
nn_term ();
rc = nn_send (s, "ABC", 3, 0);
assert (rc == -1 && errno == EBADF);
see how nn_send just fully gives up after the nn_term()? rc == -1 and errno == EBADF. exactly as promised, periodt π―
β SEE ALSO β
go read those too, iykyk π§
π AUTHORS π
This masterpiece was brought to you by:
- Martin Sustrik
<sustrik@250bpm.com> - Garrett DβAmore
<garrett@damore.org>
absolute legends, fr fr π
and that's the whole page, bestie β this version dropped on 2026-01-16 and lives in the nanomsg 1.2.2 era, so if you're reading it, you're reading the real thing. now go close your sockets properly, slay π β¨
π¦ where this page comes from
- fedora 44: nanomsg-devel 1.2.2-2.fc44 Β· MIT
- fedora 44: nanomsg-devel 1.2.2-2.fc44 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms