Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow I/O thread to be interrupted by some signal. #4748

Open
deadalnix opened this issue Oct 10, 2024 · 0 comments
Open

Allow I/O thread to be interrupted by some signal. #4748

deadalnix opened this issue Oct 10, 2024 · 0 comments

Comments

@deadalnix
Copy link

Issue description

By default, the I/O thread started by ZeroMQ block all signals. This ensure that the signal that the process receive are processes by another thread, which is what we want. However, signals are commonly used to suspend threads from within the application. For instance, the Boehm garbage collector for C and C++ does so using the SIGPWR and SIGXCPU signals on linux. On SIGUSR1 and SIGUSR2 in the case of the D garbage collector.

The code responsible for blockign all signals can be found here:

libzmq/src/thread.cpp

Lines 218 to 224 in 90b4f41

// Following code will guarantee more predictable latencies as it'll
// disallow any signal handling in the I/O thread.
sigset_t signal_set;
int rc = sigfillset (&signal_set);
errno_assert (rc == 0);
rc = pthread_sigmask (SIG_BLOCK, &signal_set, NULL);
posix_assert (rc);

Environment

  • libzmq version (commit hash if unreleased): 4.3.5 (I do believe any recent version of ZeroMQ would have the same behavior).
  • OS: Linux (Debian testing)

Minimal test code / Steps to reproduce the issue

  1. Send a signal to the worker's thread using pthread_kill .

What's the actual result? (include assertion message & call stack if applicable)

Nothing happens. In the context of the GC mentioned above, it means the programs hangs forever waiting for the thread to stop using Boehm, or the thread still running when it should have stopped for the D garbage collector.

Actual effect in practice will depend on what the signal are used for internally and via which specific protocol.

What's the expected result?

The default behavior can remain unchanged, but a ZeroMQ user should be able to specify a set of signal that needs to be exluded from the blanket signal block the I/O thread is doing on startup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant