From ec54bce037984ced01e034b482d4c8ef2f8e3787 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Tue, 6 Apr 2021 23:01:48 +0100 Subject: [PATCH] Fix mosquitto_sub pipe close detection. If sending mosquitto_sub output to a pipe, mosquitto_sub will now detect that the pipe has closed and disconnect. Closes #2164. Thanks to Frantisek Fuka. --- ChangeLog.txt | 8 ++++++++ client/sub_client.c | 3 +++ 2 files changed, 11 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index bf9b09fd..add80098 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,11 @@ +2.0.11 - 2021-xx-xx +=================== + +Clients: +- If sending mosquitto_sub output to a pipe, mosquitto_sub will now detect + that the pipe has closed and disconnect. Closes #2164. + + 2.0.10 - 2021-04-03 ================== diff --git a/client/sub_client.c b/client/sub_client.c index 72170ab2..5e5e570c 100644 --- a/client/sub_client.c +++ b/client/sub_client.c @@ -96,6 +96,9 @@ static void my_message_callback(struct mosquitto *mosq, void *obj, const struct } print_message(&cfg, message, properties); + if(ferror(stdout)){ + mosquitto_disconnect_v5(mosq, 0, cfg.disconnect_props); + } if(cfg.msg_count>0){ msg_count++;