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

Please don't ignore SIGPIPE in the mosquitto client library #2564

Closed
nmeum opened this issue Jun 11, 2022 · 2 comments
Closed

Please don't ignore SIGPIPE in the mosquitto client library #2564

nmeum opened this issue Jun 11, 2022 · 2 comments
Labels
Component: libmosquitto Status: Completed Nothing further to be done with this issue, it can be closed by the requestor or committer. Type: Bug
Milestone

Comments

@nmeum
Copy link

nmeum commented Jun 11, 2022

Hello,

Presently, the mosquitto MQTT library ignores SIGPIPE:

mosquitto/lib/mosquitto.c

Lines 112 to 114 in d5970ca

#ifndef WIN32
signal(SIGPIPE, SIG_IGN);
#endif

This is a problem since this will affect all threads of the process running the mosquitto client library. Furthermore, as per signal(7) “A child created via fork(2) inherits a copy of its parent's signal dispositions.”. That is, any process forked from the process which uses the mosquitto client library will also ignore SIGPIPE by default. I believe it to be a very bad idea to have a C library introduce this sort of side-effect since code using the C library may require SIGPIPE to not be ignored.

We noticed this at Alpine Linux where we use mosquitto as part of our build infrastructure. See:

Opening this issue here in the hopes that you might consider not modifying signal dispositions in the mosquitto library.

@ericonr
Copy link

ericonr commented Jun 17, 2022

I can think of two alternatives here:

  • use send(2) with MSG_NOSIGNAL on platforms where it's available
  • ignore the signal but with a dummy function instead, which can't be inherited (is still uncooperative behavior from a C library, but at least less disruptive for some use cases)

ralight added a commit that referenced this issue Aug 7, 2022
@ralight
Copy link
Contributor

ralight commented Aug 7, 2022

Agreed, this is bad behaviour. Thanks for pointing it out.

@ralight ralight added Type: Bug Component: libmosquitto Status: Completed Nothing further to be done with this issue, it can be closed by the requestor or committer. labels Aug 7, 2022
@ralight ralight modified the milestones: 2.0.4, 2.0.15 Aug 7, 2022
@ralight ralight closed this as completed Aug 11, 2022
algitbot pushed a commit to alpinelinux/aports that referenced this issue Aug 15, 2022
algitbot pushed a commit to alpinelinux/aports that referenced this issue Aug 15, 2022
This has been fixed by mosquitto upstream.

See: eclipse/mosquitto#2564

This reverts commit 1d5e4a4.
algitbot pushed a commit to alpinelinux/aports that referenced this issue Oct 21, 2022
algitbot pushed a commit to alpinelinux/aports that referenced this issue Oct 21, 2022
See eclipse/mosquitto#2564

(cherry picked from commit 9292d10)
(cherry picked from commit a83466b)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Component: libmosquitto Status: Completed Nothing further to be done with this issue, it can be closed by the requestor or committer. Type: Bug
Projects
None yet
Development

No branches or pull requests

3 participants