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

blocked SIGPIPE causes uninterruptible dnsjit scripts #234

Closed
pspacek opened this issue Mar 5, 2024 · 4 comments · Fixed by #235
Closed

blocked SIGPIPE causes uninterruptible dnsjit scripts #234

pspacek opened this issue Mar 5, 2024 · 4 comments · Fixed by #235

Comments

@pspacek
Copy link
Contributor

pspacek commented Mar 5, 2024

Normally scripts which use stdout can be terminated by signal SIGPIPE, i.e. when another tool in the pipeline cuts the output etc.

Dnsjit blocks SIGPIPE unconditionally and this causes scripts to run until they terminate for other reasons, even if the all the output is being dropped.

This is causing trouble in long testing pipelines which do decompress & process as separate steps in individual processes.

A minimal example:

File /tmp/out.lua

local output = io.stdout
while (true)
do
	output:write("bla\n")
end

LuaJIT behavior:

$ time luajit /tmp/out.lua | head -n1
bla

real	0m0.002s
user	0m0.002s
sys	0m0.000s

Dnsjit behavior:

$ time dnsjit /tmp/out.lua | head -n1
bla
^Ccore fatal: signal 2

real	0m3.654s
user	0m3.622s
sys	0m0.030s

I would submit MR to unblock SIGPIPE, but I'm not sure why generic block for (almost) all signals was put in place.

Current behavior stems from this piece of code:

     48 int main(int argc, char* argv[])
     49 {
...
     60     sigfillset(&set);
     61     if ((err = pthread_sigmask(SIG_BLOCK, &set, 0))) {
     62         glfatal("Unable to set blocked signals with pthread_sigmask()");
     63         return 2;
     64     }
     65 
     66     sigemptyset(&set);
     67     sigaddset(&set, SIGTERM);
     68     sigaddset(&set, SIGQUIT);
     69     sigaddset(&set, SIGINT);
     70 
     71     if ((err = pthread_create(&sighthr, 0, _sighthr, &set))) {
     72         glfatal("Unable to start signal thread with pthread_create()");
     73         return 2;
     74     }
@pspacek
Copy link
Contributor Author

pspacek commented Mar 5, 2024

LOL, I just realized it ignores also SIGSEGV.
killall -11 dnsjit does nothing.

I think that's a bit too much 😂

@jelu
Copy link
Member

jelu commented Mar 5, 2024

dnsjit goes wroooooom! no time to stop for signals! 😄 will fix

jelu added a commit to jelu/dnsjit that referenced this issue Mar 6, 2024
- Fix DNS-OARC#234: Remove signal blocking
- Format code using newer `clang-format`
@jelu jelu closed this as completed in #235 Mar 6, 2024
@jelu
Copy link
Member

jelu commented Mar 6, 2024

@pspacek @tkrizek please test this :)

cznic-knotbot pushed a commit to CZ-NIC/shotgun that referenced this issue Mar 20, 2024
Newer versions of dnsjit no longer ignore all signals sent to the
process. We need to ensure that SIGPIPE caused by a single broken
connection won't cause shotgun to end abruptly.

Related DNS-OARC/dnsjit#234
@nicki-krizek
Copy link
Contributor

Signals are now working as expected. We've just had to ignore SIGPIPE in DNS Shotgun to keep its prior behavior, otherwise all looks good. Thanks!

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

Successfully merging a pull request may close this issue.

3 participants