You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wrote a Lua script (for Linux) that opens a pipe to "mosquitto_sub" and reads incoming data from it. This works flawlessly. But when the script ends and I want to cleanly close the pipe, my script hangs indefinitely on the "fd:close()" line. I am not sure if this is a mosquitto_sub problem but I am using Lua pipes to read outputs of various CLI commands all the time and I have never experienced this behavior before - fd:close() should never hang.
This Lua script shows that closing a pipe to another command works OK but attempt to close a pipe to mosquitto_sub hangs. This script requires local mosquitto server running with default configuration so that the script can connect to it without authentication.
#!/usr/bin/env lua
local fd
print("Opening cat pipe")
fd = io.popen("cat /dev/null")
print("Trying to close cat pipe")
fd:close()
print("Closed cat pipe")
print("Opening mosquitto_sub pipe")
fd = io.popen("mosquitto_sub -t 'nonexistent_topic'")
print("Trying to close mosquitto_pub pipe")
fd:close()
print("Closed mosquitto_pub file") --This is never printed
The text was updated successfully, but these errors were encountered:
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.
I wrote a Lua script (for Linux) that opens a pipe to "mosquitto_sub" and reads incoming data from it. This works flawlessly. But when the script ends and I want to cleanly close the pipe, my script hangs indefinitely on the "fd:close()" line. I am not sure if this is a mosquitto_sub problem but I am using Lua pipes to read outputs of various CLI commands all the time and I have never experienced this behavior before - fd:close() should never hang.
This Lua script shows that closing a pipe to another command works OK but attempt to close a pipe to mosquitto_sub hangs. This script requires local mosquitto server running with default configuration so that the script can connect to it without authentication.
The text was updated successfully, but these errors were encountered: