ZMQ_CTX_DESTROY(3)

πŸ“¦
version 4.3.5 Β· 2 versions
, in arch rolling

πŸ’… ZMQ_CTX_DESTROY β€” terminate a 0MQ context πŸ’…

okay bestie, this is page ZMQ_CTX_DESTROY(3) from the 0MQ Manual, and it's literally the "bye forever" button for a context 🫢


✨ SYNOPSIS ✨

int zmq_ctx_destroy (void *context);

πŸŽ€ DESCRIPTION πŸŽ€

So zmq_ctx_destroy() shall destroy the 0MQ context context. Like, completely. It's giving end-of-erΠ° energy πŸ’€

Context termination happens in these steps, in this exact order:

  1. Any blocking operations currently in progress on sockets open within context shall return immediately with an error code of ETERM. And β€” huge caveat incoming β€” with the exception of zmq_close(), any further operations on sockets open within context shall fail with an error code of ETERM. So yeah, everything else is locked out fr fr.
  2. After interrupting all blocking calls, zmq_ctx_destroy() shall block until these conditions are satisfied:
    • All sockets open within context have been closed with zmq_close().
    • For each socket within context, all messages sent by the application with zmq_send() have either been physically transferred to a network peer, or the socket's linger period set with the ZMQ_LINGER socket option has expired.
🚨 bestie listen. Step 2 actually blocks. If your sockets aren't closed and your linger period hasn't expired, you will simply be sitting there. Not a vibe. Plan accordingly πŸ™ˆ

For further details regarding socket linger behaviour, refer to the ZMQ_LINGER option in zmq_setsockopt(3). It's all in there, iykyk 🌸

This function is deprecated by zmq_ctx_term(3). Yeah. It's the old one. Still works, still documented, but zmq_ctx_term(3) is the main character now πŸ‘‘


⭐ RETURN VALUE ⭐

The zmq_ctx_destroy() function shall return zero if successful πŸŽ‰ Otherwise it shall return -1 and set errno to one of the values defined below. No cap.


πŸ’€ ERRORS πŸ’€

  • EFAULT β€” the provided context was invalid. Rude, but okay.
  • EINTR β€” termination was interrupted by a signal. The good news: it can be restarted if needed πŸ”

πŸ¦‹ SEE ALSO πŸ¦‹

zmq(7) zmq_init(3) zmq_close(3) zmq_setsockopt(3)


πŸ‘‘ AUTHORS πŸ‘‘

This page was written by the 0MQ community 🫢 To make a change please read the 0MQ Contribution Policy at http://www.zeromq.org/docs:contributing.


and that's the whole page, bestie ✨ this was 0MQ 4.3.5, dated 02/15/2026 β€” go close your sockets, mwah πŸ’œπŸŒˆ

πŸ“¦ where this page comes from