Skip to content

Commit

Permalink
Merge pull request #7 from nmeum/sigpipe
Browse files Browse the repository at this point in the history
Restore default SIGPIPE handler after fork()
  • Loading branch information
ncopa committed Apr 7, 2022
2 parents 5ba6139 + c58f6fd commit 64bf27e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions mqtt-exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ void message_cb(struct mosquitto *mosq, void *obj,
struct userdata *ud = (struct userdata *)obj;
if (msg->payloadlen || ud->verbose) {
if (ud->command_argv && fork() == 0) {
/* mosquitto ignores SIGPIPE, this is a problem as it
* gets inherited by all processes spawned by mqtt-exec
* restore the default handler explicitly for now. */
signal(SIGPIPE, SIG_DFL);

if (ud->verbose)
ud->command_argv[ud->command_argc-2] = msg->topic;
ud->command_argv[ud->command_argc-1] =
Expand Down

0 comments on commit 64bf27e

Please sign in to comment.